-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex101.py
More file actions
27 lines (22 loc) · 886 Bytes
/
Copy pathex101.py
File metadata and controls
27 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Exercício Python 101: Crie um programa que tenha uma função chamada voto()
# que vai receber como parâmetro o ano de nascimento de uma pessoa,
# retornando um valor literal indicando se uma pessoa tem voto NEGADO, OPCIONAL e OBRIGATÓRIO nas eleições.
def voto(x=0):
from datetime import date
data = date.today().year
if nasc == 0 or nasc <= 1900:
return f'IDADE INVÁLIDA! uma pessoa com {data-nasc} não está viva!'
elif data-nasc < 18:
return f'Com {data-nasc} anos: NÃO VOTA!'
elif 18 >= data-nasc < 65:
return f'Com {data-nasc} anos: VOTO OBRIGATÓRIO!'
else:
return f'Com {data-nasc} anos: VOTO FACULTATIVO!'
#programa principal
while True:
try:
nasc = int(input('Ano de nascimento: '))
print(voto(nasc))
break
except ValueError:
print('ERRO! Digite um número inteiro')