0

Automated Quiz:I need a code elapsed time every each question, the fastest and slowest answering question time, what code I use?

class Question: def __init__(self, prompt, answer, choice): self.prompt = prompt self.answer = answer self.choice = choice MC = [ "Herbivores: a. Elephants, b. Lions, c. Plants: ", "Birds: a. Dove, b. Elephant, c. Ants: ", "Mammal: a. Dove, b. Elephant, c. Shark: ", "Insect: a. Fly, b. Dolphin, c. Lion: " ] choice = "" Q1 = Question(MC[0], "a", choice) Q2 = Question(MC[1], "a", choice) Q3 = Question(MC[2], "b", choice) Q4 = Question(MC[3], "a", choice) questions = [Q1, Q2, Q3, Q4] def run_test(questions): score = 0 for i in questions: i.choice = input(i.prompt) if i.choice == i.answer: score += 1 print("Final score: ", score,"/4") print() for i in questions: print("Question: ", i.prompt) print("Correct answer: ", i.answer) print("Your choice: ", i.choice) Print() run_test(questions)

13th Oct 2022, 4:20 PM
John Vel Llacuna
John Vel Llacuna - avatar
2 odpowiedzi
+ 1
start with get questions elapsed times like: import time ...... questions_times=[] for i in questions: now= time.time() i.choice = input(i.prompt) questions.append(time.time() - now) ....
13th Oct 2022, 5:37 PM
KrOW
KrOW - avatar
0
You might not even need OOP. (Sololearn's playground really isn't very good for console app.... interactive console and timer does not work here.🙁) https://code.sololearn.com/cqAUkDJ41OX6/?ref=app
13th Oct 2022, 10:40 PM
Bob_Li
Bob_Li - avatar