-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaula_124.py
50 lines (40 loc) · 1.13 KB
/
aula_124.py
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
perguntas = [
{
'Pergunta': 'Quanto é 2+2?',
'Opções': ['1', '2', '3', '4', '5'],
'Resposta': '4',
},
{
'Pergunta': 'Quanto é 5*5?',
'Opções': ['25', '55', '10', '51'],
'Resposta': '25',
},
{
'Pergunta': 'Quanto é 10/2?',
'Opções': ['4', '5', '2', '1'],
'Resposta': '5',
}
]
quantidade_acertos = 0
for pergunta in perguntas:
print('Pergunta:', pergunta['Pergunta'])
opcoes = pergunta['Opções']
for i, opcao in enumerate(opcoes):
print(f'({i})', opcao)
escolha = input('Escolha uma opção: ')
acertou = False
escolha_int = None
quantidade_opcoes = len(opcoes)
if escolha.isdigit():
escolha_int = int(escolha)
if escolha_int is not None:
if escolha_int >= 0 and escolha_int < quantidade_opcoes:
if opcoes[escolha_int] == pergunta['Resposta']:
acertou = True
if acertou:
quantidade_acertos += 1
print('Resposta certa!')
else:
print('Erroooooou!')
print()
print('Total de respostas corretas: ', quantidade_acertos)