Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # program to check if imei number valid or not - open source totaly free
- from PyQt6.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QVBoxLayout, QWidget
- import sys
- class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- self.setWindowTitle("My App")
- self.label = QLabel()
- self.input = QLineEdit()
- self.input.textChanged.connect(self.func)
- layout = QVBoxLayout()
- layout.addWidget(self.input)
- layout.addWidget(self.label)
- container = QWidget()
- container.setLayout(layout)
- # Set the central widget of the Window.
- self.setCentralWidget(container)
- # Driver code
- def func(self, n):
- def sumDig( n ):
- a = 0
- while n > 0:
- a = a + n % 10
- n = int(n / 10)
- return a
- # Returns True if n is valid EMEI
- def isValidEMEI(n):
- # Converting the number into
- # String for finding length
- s = str(n)
- l = len(s)
- # If leng+th is not 15 then IMEI is Invalid
- if l != 15:
- return False
- d = 0
- sum = 0
- for i in range(15, 0, -1):
- d = (int)(int(n) % 10)
- if i % 2 == 0:
- # Doubling every alternate digit
- d = 2 * d
- # Finding sum of the digits
- sum = sum + sumDig(d)
- n = int(n) / 10
- return (sum % 10 == 0)
- if isValidEMEI(n):
- self.label.setText("\nValid IMEI Code\n")
- else:
- self.label.setText("WRONG or Invalid IMEI")
- app = QApplication(sys.argv)
- window = MainWindow()
- window.show()
- app.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement