-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (29 loc) · 1.15 KB
/
main.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
from random import randint
from data import Question, questions_answers_full
print("\n" * 20)
print("Welcome to the Orientation AI Quizz!")
print("There are 10 questions. Type 'A', 'B', 'C' or 'D'. ")
print("\n")
score = 0
def check_answer(user_answer, correct_answer, question_number):
if user_answer.lower() == correct_answer.lower():
global score
score += 1
print("You got it right!")
else:
print(f"You got it wrong! The correct answer was: {questions_answers_full[question_number]["answer"]}")
print("\n")
which_questions = list()
for i in range(10):
which_questions.append(randint(1, 100))
for i in which_questions:
print(f"Question nr {i + 1}: ")
print(questions_answers_full[i]["question"])
print(f"A) {questions_answers_full[i]["A"]}")
print(f"B) {questions_answers_full[i]["B"]}")
print(f"C) {questions_answers_full[i]["C"]}")
print(f"D) {questions_answers_full[i]["D"]}")
print(f"E) {questions_answers_full[i]["E"]}")
user_guess = input(f"Your answer: ")
check_answer(user_guess, questions_answers_full[i]["answer"], i)
print(f"Congratulations! You got {(score/10) * 100}%")