-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex_dict_perg_resp.py
50 lines (41 loc) · 1.24 KB
/
ex_dict_perg_resp.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
print()
print('Texto explicativo')
perguntas = {
'Pergunta 1': {
'pergunta': 'Quanto é 2+2? ',
'respostas': {
'a': '1',
'b': '4',
'c': '5',
},
'resposta_certa': 'b',
},
'Pergunta 2': {
'pergunta': 'Quanto é 3x2? ',
'respostas': {
'a': '4',
'b': '101',
'c': '6',
},
'resposta_certa': 'c',
},
}
print()
respostas_certas = 0
for pergunta, dados_pergunta in perguntas.items():
print(f'{pergunta}: {dados_pergunta["pergunta"]}')
print('Respostas: ')
for resposta, dados_resposta in dados_pergunta['respostas'].items():
print(f'[{resposta}]: {dados_resposta}')
resposta_usuario = input('Sua resposta: ')
if resposta_usuario == dados_pergunta['resposta_certa']:
print('EHHHHHH!!! Você acertou!!!!')
respostas_certas += 1
else:
print('IXXIIIII!!! Você ERROU!!!!')
print()
quantidade_perguntas = len(perguntas)
porcentagem_acerto = respostas_certas / quantidade_perguntas * 100
print(f'Você acertou {respostas_certas} respostas.')
print(f'Sua porcentagem de acerto foi {porcentagem_acerto}%.')
#@RafaelPinheiroLimaCoder - ex_dicionarios_python_aula_56.py