Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 030601e

Browse files
Update quiz.py
1 parent 52c0f44 commit 030601e

File tree

1 file changed

+5
-97
lines changed

1 file changed

+5
-97
lines changed

‎Quiz_Game/quiz.py‎

Lines changed: 5 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,177 +2,85 @@
22
# List of questions for quiz
33

44
questions =[
5-
65
'who is the developer of Python Language',
7-
86
'when did india gets independence',
9-
107
'what is the Indian currency',
11-
128
'Who is World first cloned human baby',
13-
149
'who is the founder of Hinduism'
15-
1610
]
1711

18-
19-
2012
# list of answers for above questions
2113

22-
23-
2414
answers = [
25-
2615
'Guido Van',
27-
2816
'1947',
29-
3017
'INR',
31-
3218
'Eve',
33-
3419
'No Specific'
35-
3620
]
3721

38-
39-
4022
# List of options for above questions
4123

42-
43-
4424
options= [
45-
4625
['Dennis Ritchie','Alan Frank','Guido Van','Albert'],
47-
4826
['1947','1995','1950','1957'],
49-
5027
['DOLLARS','YEN','EURO','INR'],
51-
5228
['Erik','Maria','Sophie','Eve'],
53-
5429
['Mahavira Swami','Mahatma Buddha','No Specific','Prophet Mohammed']
55-
5630
]
5731

58-
59-
6032
# Quiz Game | Designed by Ishita
6133

62-
63-
6434
# Defining function for game playing
6535

66-
67-
6836
def play_game(username,questions,answers,options):
69-
7037
print("Hello,", username, "welcome to the QUIZ game")
71-
7238
print("All the Best for the Game :>")
73-
7439
score = 0
75-
7640
for i in range(5):
77-
7841
current_questions = questions[i]
79-
8042
# print(questions[i])
81-
8243
correct_answer = answers[i]
83-
8444
current_question_options = options[i]
85-
8645
print("Questions:" ,current_questions)
87-
8846
for index,each_options in enumerate(current_question_options):
89-
9047
print(index+1,") ",each_options,sep='')
91-
9248
user_answer_index = int(input("Please enter your choice(1,2,3,4): "))
93-
9449
user_answer = current_question_options[user_answer_index-1]
95-
9650
if user_answer== correct_answer:
97-
9851
print("correct answer")
99-
10052
score = score +100
101-
10253
else:
103-
10454
print("wrong answer")
105-
10655
break
107-
10856
print("Your final score is", score)
109-
11057
return username,score
111-
112-
113-
58+
11459
# Defining function for viewing the score
11560

116-
117-
11861
def view_scores(names_and_scores):
119-
12062
for name,score in names_and_scores.items():
121-
12263
print(name,"has scored",score)
123-
124-
125-
126-
# Defining the function for start of the game
127-
12864

65+
# Defining the function for start of the score
12966

13067
def quiz(questions,answers,options):
131-
132-
133-
13468
names_and_scores = {}
135-
13669
while True:
137-
13870
print("Welcome to the quiz game")
139-
14071
print("1) Play\n2) View Scores\n3) Exit")
141-
14272
choice=int(input("Please enter your choice: "))
143-
14473
if choice == 1:
145-
14674
username =(input("Please enter your name: "))
147-
14875
username,score = play_game(username,questions,answers,options)
149-
15076
names_and_scores[username] = score
151-
152-
153-
154-
155-
15677
elif choice ==2:
157-
158-
view_scores(names_and_scores)
159-
160-
161-
78+
view_scores(names_and_scores)
16279
elif choice ==3:
163-
16480
break
165-
166-
167-
16881
else :
82+
print("Your choice is not correct")
16983

170-
print("Your choice is not correct")
171-
172-
173-
174-
# Program execution starts from here
175-
176-
84+
# Program execution starts from here
17785

17886
quiz(questions,answers,options)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /