Day-27 Exercise-Game

Create a program capable of displaying questions to the user like KBC. Use List data type to store the questions and their correct answers. Display the final amount the person is taking home after playing the game.
Answer
# KBC Quiz Game
questions = [
["What is the capital of Pakistan?",
"A. Karachi", "B. Islamabad", "C. Lahore", "D. Peshawar", "B"],
["Which planet is known as the Red Planet?",
"A. Venus", "B. Jupiter", "C. Mars", "D. Saturn", "C"],
["Who is known as the Father of Computers?",
"A. Charles Babbage", "B. Newton", "C. Einstein", "D. Tesla", "A"],
["What is the largest ocean on Earth?",
"A. Atlantic", "B. Indian", "C. Arctic", "D. Pacific", "D"],
["How many continents are there in the world?",
"A. 5", "B. 6", "C. 7", "D. 8", "C"]
]
prize_money = [1000, 5000, 10000, 50000, 100000]
amount_won = 0
print("Welcome to KBC!\n")
for i in range(len(questions)):
q = questions[i]
print(f"\nQuestion {i + 1} for Rs. {prize_money[i]}")
print(q[0])
for option in q[1:5]:
print(option)
answer = input("Enter your answer (A/B/C/D): ").upper()
if answer == q[5]:
print("Correct Answer!")
amount_won = prize_money[i]
else:
print("Wrong Answer!")
print(f"The correct answer was {q[5]}")
break
print("\nGame Over!")
print("You are taking home Rs.", amount_won)
Output:
Welcome to KBC!
Question 1 for Rs. 1000
What is the capital of Pakistan?
A. Karachi
B. Islamabad
C. Lahore
D. Peshawar
Enter your answer (A/B/C/D): B
Correct Answer!
...
Game Over!
You are taking home Rs. 100000




