Identifique o recurso expressivo.
Por favor, aguarde enquanto o programa carrega.
question = ['"Booooo!"', '"Não fazes nada. Vais receber o prémio de melhor funcionário."', '"Uma flor mais bela que uma escultura."', '"A casa deles era uma prisão"', '"Eu, o António, a Maria, o Manel"']
option_A = ['onomatopeia', 'ironia', 'comparação', 'metáfora', 'enumeração']
option_B = ['_', '_', '_', '_', '_']
option_C = ['_', '_', '_', '_', '_']
option_D = ['_', '_', '_', '_', '_']
option_E = ['_', '_', '_', '_', '_']
example = ['_', '_', '_', '_', '_']
import time
import random
from js import alert, prompt, localStorage, window
n_questions = int(prompt("Quantas perguntas?", "5"))
localStorage.setItem("n_questions", n_questions)
deltas = []
correct = 0
print('============= INÍCIO')
randoms = []
wrongs = []
for i in range(n_questions):
done = 0
while done == 0:
rand = random.randint(0, len(question)-1)
if rand not in randoms:
randoms.append(rand)
done = 1
for i in range(len(randoms)):
index = randoms[i]
start = time.time()
user_answer = str(prompt('P: ' + str(question[index]) + ' >>> '))
if str(option_A[index]).lower() == user_answer.lower() or str(option_B[index]).lower() == user_answer.lower() or str(option_C[index]).lower() == user_answer.lower() or str(option_D[index]).lower() == user_answer.lower() or str(option_E[index]).lower() == user_answer.lower():
result = 'Correto!'
correct += 1
else:
result = 'Incorreto. A resposta correta é: ' + str(option_A[index])
wrongs.append(randoms[i])
delta = round(time.time() - start, 2)
deltas.append(delta)
alert(result)
print('P: ' + question[index])
print('R: ' + user_answer.lower())
print(result)
print(str(delta)+' s')
print('=============')
print('============= FIM')
alert(str(round(100*correct/n_questions,1))+'%'+' com tempo de resposta médio de: '+ str(round(sum(deltas)/len(deltas),2)) + ' s')
print('Número de perguntas: ' + str(n_questions))
print('Nota: '+str(round(100*correct/n_questions,1))+'%'+' com tempo de resposta médio de: '+ str(round(sum(deltas)/len(deltas),2)) + ' s')
if len(wrongs)>0:
user_answer = str(prompt("Corrigir as erradas? Introduza 'sim' or 'não'. >>> "))
if user_answer.lower() == 'sim':
randoms = wrongs
print('============= INÍCIO #2')
correct = 0
deltas = []
for i in range(len(randoms)):
index = randoms[i]
start = time.time()
user_answer = str(prompt('Q: ' + str(question[index]) + ' >>> '))
if str(option_A[index]).lower() == user_answer.lower() or str(option_B[index]).lower() == user_answer.lower() or str(option_C[index]).lower() == user_answer.lower() or str(option_D[index]).lower() == user_answer.lower() or str(option_E[index]).lower() == user_answer.lower():
result = 'Correto!'
correct += 1
else:
result = 'Incorreto. A resposta correta é: ' + str(option_A[index])
delta = round(time.time() - start, 2)
deltas.append(delta)
alert(result)
print('P: ' + question[index])
print('R: ' + user_answer.lower())
print(result)
print(str(delta)+' s')
print('=============')
print('============= FIM #2')
alert(str(round(100*correct/len(wrongs),1))+'%'+' com tempo de resposta médio de: '+ str(round(sum(deltas)/len(deltas),2)) + ' s')
print('Número de perguntas: ' + str(len(wrongs)))
print('Nota: '+str(round(100*correct/len(wrongs),1))+'%'+' com tempo de resposta médio de: '+ str(round(sum(deltas)/len(deltas),2)) + ' s')
print('Atualize a página para jogar novamente.')