-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQUIZZNEW.py
More file actions
59 lines (48 loc) · 2.14 KB
/
QUIZZNEW.py
File metadata and controls
59 lines (48 loc) · 2.14 KB
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
51
52
53
54
55
56
57
58
59
# ANSI escape codes for colors
GREEN = '\033[92m'
RED = '\033[91m'
ENDC = '\033[0m' # Reset color
def print_separator():
print("^*^*^*^*^*^*^*^*^*^*^*")
def check_answer(user_guess, correct_answer):
return user_guess == correct_answer
score = 0
questions = [
{"text": "Which country is known as the 'Land of the Rising Sun'?", "Answer": "B"},
{"text": "The Great Barrier Reef is located off the coast of which country?", "Answer": "B"},
{"text": "In which mountain range is Mount Everest located?", "Answer": "A"},
{"text": "Which river is the longest in the world?", "Answer": "C"},
{"text": "Which ocean is the largest by area?", "Answer": "D"}
]
options = [
["A. China", "B. Japan", "C. South Korea", "D. Thailand"],
["A. Mexico", "B. Australia", "C. Brazil", "D. Thailand"],
["A. Himalayas", "B. Alps", "C. Rocky Mountains", "D. Andes"],
["A. Amazon River", "B. Mississippi River", "C. Nile River", "D. Yangtze River"],
["A. Atlantic Ocean", "B. Indian Ocean", "C. Southern Ocean", "D. Pacific Ocean"]
]
# Welcome message
print("WELCOME TO MY QUIZ GAME!")
print("LET'S TEST YOUR GENERAL KNOWLEDGE.GOOD LUCK !")
for ques_num in range(len(questions)):
print(" ")
print_separator()
print(questions[ques_num]["text"])
for i in options[ques_num]:
print(i)
guess = input("Enter Your Answer (A/B/C/D): ").upper()
is_correct = check_answer(guess, questions[ques_num]["Answer"])
if is_correct:
print(GREEN + "** CORRECT ANSWER **" + ENDC)
score += 1
else:
print(RED + "** INCORRECT ANSWER **" + ENDC)
print("!!!!!!!!!!!")
print(f" CORRECT ANSWER IS {questions[ques_num]['Answer']} ")
print(f"YOUR CURRENT SCORE ---> {score}/{ques_num + 1}")
percentage_score = score / len(questions) * 100
percentage_emoji = '🎉' if percentage_score >= 70 else '😕' # Choose emojis based on the percentage
print("\n" + "=" * 30)
print(f"YOU HAVE GIVEN {score} CORRECT ANSWERS")
print(f"YOUR SCORE PERCENTAGE IS --> {percentage_score:.2f}% {percentage_emoji}")
print("=" * 30)