-
Notifications
You must be signed in to change notification settings - Fork 31
/
KBCquiz.py
205 lines (186 loc) · 7.92 KB
/
KBCquiz.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Importing necessary modules
import random # For random selection of questions and options
import time # For adding delays to simulate a dynamic quiz experience
# Print 120 asterisks for visual effect
for i in range(120):
print("*", end="")
time.sleep(0)
# Print the welcome message
print()
print("\t\t\t Welcome to")
print("\t\t\t Kaun Banega Crorepati")
# Print another line of asterisks
for i in range(120):
print("*", end="")
time.sleep(0)
print()
# Ask the user to input their name
a = input("\t Enter Your Name - ")
# Print another line of asterisks
for i in range(120):
print("*", end="")
time.sleep(0)
print()
# Welcome message with the player's name
print("\n\tOK ", a, " Let's Start The Game")
time.sleep(1)
# List of questions and their corresponding answers
questions = [
"Who is The Prime Minister of India",
"In Which Country Area 51 is Located",
"Which one is the largest Continent in the world",
"What is the Latest Version of Windows Since 2019",
"Which One of These Is not a Software Company",
"How Many MB Makes 1 GB",
"Facebook Was Firstly Developed By",
"Founder of Apple is",
"_________ is one of The Founder of Google",
"BIGG BOSS season 13 Starts in ____ & ends in _____",
"Apple's Laptop is Also Known as",
"First Apple Computer is Known as",
"Joystick is used For",
"____________ is used to Encrypt Drives in Computer"
]
answer = [
"Narendra Modi", "United States", "Asia", "Windows 11", "Honda", "1024",
"Mark Zuckerberg", "Steve Jobs", "Larry Page", "2019 - 2020", "Macbook",
"Mactonish", "Playing Games", "Bitlocker"
]
# List of wrong answers for each question (to generate multiple choices)
wronganswers = [
["Amit Shah", "Aditya Nath Yogi", "Azhar Ansari"],
["India", "Africa", "Iraq"],
["South Africa", "North America", "Europe"],
["Windows 7", "Windows 8", "Windows 10"],
["Oracle", "Microsoft", "Google"],
["10024", "1004", "2024"],
["Bill Gates", "Larry Page", "Azhar Ansari"],
["Azhar Ansari", "Charles Babbage", "Sundar Pichai"],
["Larry Hensberg", "Sunder Pichai", "Bill Gates"],
["2020 - 2021", "Not Starts Now", "2018 - 2019"],
["ThinBook", "Notebook", "ChromeBook"],
["Apple v.1", "Apple Computer", "Appbook"],
["Giving output command", "Shutting down Computer", "Log off Computer"],
["KeyGuard", "Windows Secure", "No Software like this"]
]
# Initialize variables for attempted questions, question count, and prize amount
attempquestion = []
count = 1
amount = 0
# Start the game loop
while True:
# Select a question that hasn't been asked yet
while True:
selectquestion = random.choice(questions)
if selectquestion in attempquestion:
pass # Skip if the question was already asked
else:
attempquestion.append(selectquestion) # Add the question to the attempted list
questionindex = questions.index(selectquestion) # Find the index of the selected question
correctanswer = answer[questionindex] # Get the correct answer for the question
break
# Generate multiple choice options
optionslist = []
inoptionlist = []
optioncount = 1
while optioncount < 4: # Pick three wrong answers
optionselection = random.choice(wronganswers[questionindex])
if optionselection not in inoptionlist:
optionslist.append(optionselection)
inoptionlist.append(optionselection)
optioncount += 1
optionslist.append(correctanswer) # Add the correct answer to the options list
# Shuffle and display the options in random order
alreadydisplay = []
optiontodisplay = []
for _ in range(4):
while True:
a = random.choice(optionslist)
if a not in alreadydisplay:
alreadydisplay.append(a)
optiontodisplay.append(a)
break
# Identify the correct option label (a, b, c, d)
right_answer = ""
if correctanswer == optiontodisplay[0]:
right_answer = "a"
elif correctanswer == optiontodisplay[1]:
right_answer = "b"
elif correctanswer == optiontodisplay[2]:
right_answer = "c"
elif correctanswer == optiontodisplay[3]:
right_answer = "d"
# Display the question and options
print("--------------------------------------------------------------------------------------------")
print("\t\t\tAmount Win - ", amount)
print("--------------------------------------------------------------------------------------------")
time.sleep(1)
print("\n\t\tQuestion ", count, " on your Screen")
print("--------------------------------------------------------------------------------------------")
time.sleep(1)
print(" | Question - ", selectquestion)
print("--------------------------------------------------------------------------------------------")
time.sleep(1)
print("\t| A. ", optiontodisplay[0])
print("\t-----------------------------------------------------------------------------")
time.sleep(1)
print("\t| B. ", optiontodisplay[1])
print("\t-----------------------------------------------------------------------------")
time.sleep(1)
print("\t| C. ", optiontodisplay[2])
print("\t-----------------------------------------------------------------------------")
time.sleep(1)
print("\t| D. ", optiontodisplay[3])
print("\t-----------------------------------------------------------------------------")
# Ask the player for their answer
useranswer = input("\t\tEnter Correct Option\t or \t press Q to quit.\n\t\t\t...").lower()
# Check if the answer is correct
if useranswer == right_answer:
# Update the prize amount based on the number of correct answers
if count == 1:
amount = 10000
elif count == 2:
amount = 20000
elif count == 3:
amount = 50000
elif count == 4:
amount = 100000
elif count == 5:
amount = 400000
elif count == 6:
amount = 800000
elif count == 7:
amount = 1600000
elif count == 8:
amount = 3200000
elif count == 9:
amount = 6400000
elif count == 10:
amount = 10000000 # Maximum prize for answering all questions correctly
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
print("*********************************************************************************")
print("\t\t\t !!!!!!!!!! Congratulations! !!!!!!!!!!")
print("\t\t\t||||||||||| You Won The Game |||||||||||")
print("*********************************************************************************")
print("\n\n\t\t You Won Rs. ", amount)
print()
break
# Display message for correct answer and proceed to the next question
print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
print("*********************************************************************************")
print("\t\t\t !!!!!!!!!! Congratulations! !!!!!!!!!!")
print("\t\t\t||||||||||||| Right Answer ||||||||||||||")
print("*********************************************************************************")
count += 1
# If the player chooses to quit
elif useranswer == "q":
print("\n\n\t\t You Won Rs. ", amount)
break
# If the player provides a wrong answer
else:
print("*********************************************************************************")
print("\t\t\t\t\t\t\t\t Wrong Answer")
print("*********************************************************************************")
print("\n\n\t\t \t\t\t\t\t\t You Won Rs. ", amount)
print("*********************************************************************************")
break