-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathquiz_game.py
More file actions
90 lines (79 loc) · 1.89 KB
/
quiz_game.py
File metadata and controls
90 lines (79 loc) · 1.89 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
Project: Simple Quiz Game
Author:Revathi M
Description:
Create a simple quiz game that asks the user a few questions and calculates the score.
Requirements:
1. Display at least 5 questions.
2. Ask the user to input their answer.
3. Check if the answer is correct.
4. Increase the score for each correct answer.
5. Display the final score at the end of the quiz.
Sample Output:
Question 1: What is the capital of France?
Your answer: Paris
Correct!
Question 2: What is 5 + 3?
Your answer: 8
Correct!
Final Score: 2/2
"""
print("Welcome to the Quiz Game")
score=0
print("\n1. What is the capital of India?")
print("1. Mumbai")
print("2. Delhi")
print("3. Chennai")
print("4. Kolkata")
ans = input("Enter your option (1-4): ")
if ans == "2":
print("Correct answer")
score = score + 1
else:
print("Wrong answer")
print("\n2. What is 5 + 3?")
print("1. 6")
print("2. 7")
print("3. 8")
print("4. 9")
ans_1 = input("Enter your option (1-4): ")
if ans_1 == "3":
print("Correct answer")
score = score + 1
else:
print("Wrong answer")
print("\n3. Which of the following is used to take input from the user in Python?")
print("1. print()")
print("2. input()")
print("3. read()")
print("4. scan()")
ans_2= input("Enter your option (1-4): ")
if ans_2 == "2":
print("Correct answer")
score = score + 1
else:
print("Wrong answer")
print("\n4. What is the square of 4?")
print("1. 8")
print("2. 12")
print("3. 16")
print("4. 20")
ans_3 = input("Enter your option (1-4): ")
if ans_3 == "3":
print("Correct answer")
score = score + 1
else:
print("Wrong answer")
print("\n5. How many days are there in a week?")
print("1. 5")
print("2. 6")
print("3. 7")
print("4. 8")
ans_4 = input("Enter your option (1-4): ")
if ans_4 == "3":
print("Correct answer")
score = score + 1
else:
print("Wrong answer")
print("\nQuiz Finished")
print("Your final score is:", score)