-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidade.py
More file actions
51 lines (40 loc) · 1.42 KB
/
Copy pathidade.py
File metadata and controls
51 lines (40 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Exercício : idade
# Perguntar anos de nasc e ano atual, retirnar idade e perguntar se deseja novo teste
executar = True
while executar :
anoNasc = int(input("Em que ano você nasceu? "))
anoAtual = int(input("Em que ano estamos? "))
idade = anoAtual - anoNasc
print("Você tem: ", idade, "anos")
pergunta = input("Deseja testar novamente? ")
if pergunta == "não":
executar = False
# Mesma coisa, porém mais bonitinho
"""
executar = True
while executar :
anoNasc = int(input("Em que ano você nasceu? "))
anoAtual = int(input("Em que ano estamos? "))
idade = anoAtual - anoNasc
print("Você tem: ", idade, "anos")
pergunta = input("\n Deseja testar novamente? \n [1]SIM \n [2]NÃO \n")
if pergunta == "2":
executar = False
"""
print("----------- Segundo Exercicio Usando Funções-------------")
def calcular_idade() :
anoNsc = int(input("Em que ano você nasceu? "))
anoAtl = int(input("Em que ano estamos? "))
idade = anoAtl - anoNsc
print("Você tem " + str(idade) + "anos. ")
def perguntar_novamente():
opcao = input("deseja testar novamente? sim ou Não: ")
if opcao.lower() in ["Sim", "s"] :
iniciarprograma()
else:
print("Encerrando programa! Até mais 😎")
def iniciarprograma():
calcular_idade()
perguntar_novamente()
# Chamada inicial
iniciarprograma()