Untitled
unknown
plain_text
a year ago
1.3 kB
4
Indexable
pesel = str(input('Podaj numer PESEL: ')) #************************************************************ # nazwa funkcji: jakaPlec # opis funkcji: funkcja sprawdza, czy przedostatnia cyfra peselu jest parzysta # parametry: pesel - wczytany przez użytkownika numer pesel (w stringu) # zwracany typ i opis: string - zwracane jest "K" w przypadku cyfry parzystej oraz "M" w przypadku cyfry nieparzystej #************************************************************ def jakaPlec(pesel): if int(pesel[9]) % 2 == 0: return 'K' else: return 'M' def sprawdzanieSumyKontrolnej(pesel): S = int(pesel[0])*1 + int(pesel[1])*3 + int(pesel[2])*7 + int(pesel[3])*9 + int(pesel[4])*1 + int(pesel[5])*3 + int(pesel[6])*7 + int(pesel[7])*9 + int(pesel[8])*1 + int(pesel[9])*3 M = S % 10 if M == 0: R = 0 else: R = 10-M if R == int(pesel[-1]): return True else: return False #testowanie if jakaPlec(pesel) == 'K': print('Kobieta') else: print('Mężczyzna') if sprawdzanieSumyKontrolnej(pesel) == True: print('Zgodność sumy kontrolnej w oparciu o podany numer PESEL') else: print('Niezgodność sumy kontrolnej w oparciu o podany numer PESEL')
Editor is loading...
Leave a Comment