Untitled
unknown
plain_text
2 years ago
1.2 kB
7
Indexable
#*******************************************
#nazwa funkcji: plec
#opis funkcji: określanie płci na podstawie przedostatniej cyfry nr pesel
#parametry: pesel - tablica 11 cyfr całkowitych tworzące pesel
#zwracany typ i opis: typ znakowy char zwraca wartość płci 'K' lub 'M'
#*******************************************
def plec(pesel):
if int(pesel[9]) % 2 == 0:
return 'K'
else:
return 'M'
def suma(pesel):
waga = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3]
poprawnaSuma = int(pesel[10])
s = 0
for i in range(10):
s += int(pesel[i])*waga[i]
m = s % 10
if m == 0:
r = 0
else:
r = 10 - m
if r == poprawnaSuma:
return True
else:
return False
pesel = list(input("podaj numer pesel"))
if len(pesel) !=11 :
print("niepoprawny numer pesel, wprowadż 11 cyfr")
else:
if plec(pesel) == 'K':
print("Kobieta")
else:
print("Mężczyzna")
if suma(pesel):
print("Suma kontrolna się zgadza")
else:
print("Suma kontrolna się nie zgadza")
Editor is loading...
Leave a Comment