Q.Participating in a quiz can be fun as it provides a competitive element. Some educational institutes use it as a tool to measure knowledge level, abilities and/or skills of their pupils either on a general level or in a specific field of study. Identify and analyse popular quiz shows and write a Python program to create a quiz that should also contain the following functionalities besides the one identified by you as a result of your analysis.
• Create an administrative user ID and password to categorically add or modify delete a question.
• Register the student before allowing her/him to play a quiz.
• Allow selection of category based on subject area.
• Display questions as per the chosen category.
• Keep the score as the participant plays.
• Display final score.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Analysing shows like Kaun Banega Crorepati suggests two extra features — show the correct answer immediately after each attempt, and keep a running score visible.
The program below layers those on top of every required feature: admin login with add/modify/delete of questions, student registration, category choice, category-wise questions, live scoring and a final score.
Step 1 — Analysis of popular quiz shows
Shows like Kaun Banega Crorepati (KBC) and school-level quiz contests share a recognisable pattern: multiple-choice questions, one category/topic at a time, feedback right after each answer, and a visible running score that builds suspense. From this analysis the additional functionality I chose to add is:
- Instant feedback — after every question, tell the player whether they were right, and show the correct option if not.
- Running score display — the score is shown after each question, not only at the end.
Step 2 — Data design (why these structures?)
question_bank— a dictionary of categories, each mapping to a list of question dictionaries{"q":…, "options":[…], "ans":…}. Categories become menu choices for free (question_bank.keys()), and add/modify/delete are plain list operations.students— a dictionaryuser_id → namefor registration.- Admin credentials are checked before any change to the bank.
Step 3 — The program
ADMIN_ID, ADMIN_PASS = "admin", "quiz@123"
question_bank = {
"Science": [
{"q": "Which gas do plants absorb for photosynthesis?",
"options": ["Oxygen", "Carbon dioxide", "Nitrogen", "Hydrogen"],
"ans": 2},
],
"History": [
{"q": "Who built the Taj Mahal?",
"options": ["Akbar", "Aurangzeb", "Shah Jahan", "Babur"],
"ans": 3},
],
}
students = {} # user_id -> name
def admin_login():
uid = input("Admin ID : ")
pwd = input("Password : ")
return uid == ADMIN_ID and pwd == ADMIN_PASS
def add_question():
cat = input("Category: ").title()
question_bank.setdefault(cat, []) # new category auto-created
q = input("Question text: ")
options = [input(f"Option {i}: ") for i in range(1, 5)]
ans = int(input("Correct option number (1-4): "))
question_bank[cat].append({"q": q, "options": options, "ans": ans})
print("Question added.")
def modify_or_delete(delete=False):
cat = input("Category: ").title()
if cat not in question_bank or not question_bank[cat]:
print("No questions in that category.")
return
for i, item in enumerate(question_bank[cat], 1):
print(f"{i}. {item['q']}")
idx = int(input("Question number: ")) - 1
if not 0 <= idx < len(question_bank[cat]):
print("Invalid number.")
return
if delete:
question_bank[cat].pop(idx)
print("Question deleted.")
else:
q = input("New question text: ")
options = [input(f"Option {i}: ") for i in range(1, 5)]
ans = int(input("Correct option number (1-4): "))
question_bank[cat][idx] = {"q": q, "options": options, "ans": ans}
print("Question modified.")
def register_student():
uid = input("Choose a user ID: ")
if uid in students:
print("That ID is taken.")
return None
students[uid] = input("Your name: ")
print(f"Registered! Welcome, {students[uid]}.")
return uid
def play_quiz(uid):
print("Categories:", ", ".join(question_bank))
cat = input("Choose a category: ").title()
if cat not in question_bank or not question_bank[cat]:
print("No questions in that category yet.")
return
score = 0
for item in question_bank[cat]: # questions of chosen category
print("\n" + item["q"])
for i, opt in enumerate(item["options"], 1):
print(f" {i}. {opt}")
try:
guess = int(input("Your answer (1-4): "))
except ValueError:
guess = 0
if guess == item["ans"]:
score += 1
print("Correct!", end=" ")
else:
right = item["options"][item["ans"] - 1]
print(f"Wrong — correct answer: {right}.", end=" ")
print(f"Score so far: {score}") # KBC-style running score
print(f"\n{students[uid]}, your FINAL SCORE in {cat}: "
f"{score}/{len(question_bank[cat])}")
def main():
uid = None
while True:
print("\n1. Admin: add question\n2. Admin: modify question"
"\n3. Admin: delete question\n4. Register student"
"\n5. Play quiz\n6. Exit")
choice = input("Enter choice (1-6): ")
if choice in ("1", "2", "3"):
if not admin_login():
print("Admin authentication failed.")
elif choice == "1":
add_question()
else:
modify_or_delete(delete=(choice == "3"))
elif choice == "4":
uid = register_student()
elif choice == "5":
if uid is None: …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.