Advertisement
programusy

Untitled

Apr 5th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def check_sum(pesel):
  2. weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3, 1]
  3. pesel_digits = [int(digit) for digit in pesel]
  4.  
  5. if len(pesel_digits) != 11:
  6. print("Numer PESEL musi mieć dokładnie 11 cyfr.")
  7. return False
  8.  
  9. calculated_sum = sum(p * w for p, w in zip(pesel_digits, weights))
  10. return calculated_sum % 10 == 0
  11.  
  12. def main():
  13. pesel = input("Podaj numer PESEL: ")
  14.  
  15. if check_sum(pesel):
  16. print("Numer PESEL jest prawidłowy.")
  17. else:
  18. print("Numer PESEL jest nieprawidłowy.")
  19.  
  20. if __name__ == "__main__":
  21. main()
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement