Wastebinonpastebin

barcode_scan

Sep 25th, 2020 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. bc = input("Geben Sie einen Barcode ein: ") #bc = Barcode
  2.  
  3. def stringcheck():
  4.  
  5.     if len(bc) == 30: #tests if "bc" has 30 characters
  6.         pass
  7.     else:
  8.         print("Error: Der Barcode hat keine 30 Zeichen!")
  9.  
  10.     if bc.isdecimal(): #tests if "bc" only has digits
  11.         return True
  12.     else:
  13.         print("Fehlercode 1")
  14.  
  15.  
  16. def weightcheck():
  17.  
  18.     ng = int(bc[8:13]) #gives ng (=Bruttogewicht) the value of the index 9-13 of "bc"
  19.     bg = int(bc[18:23]) #gives bg (=Bruttogewicht) the value of the index 19-23 of "bc"
  20.  
  21.     if ng > bg:
  22.         print("Fehlercode 2")
  23.         exit()
  24.     else:
  25.         return True
  26.  
  27.  
  28. if stringcheck() and weightcheck() is True:
  29.     print("Fehlercode 0")
  30. else:
  31.     pass
  32.  
  33. stringcheck()
  34. weightcheck()
Add Comment
Please, Sign In to add comment