Skip to content

Quiz game

Orla Hi! Navigation recertification is in three weeks and I really need to revise. Can you build a multiple choice quiz I can load questions into? Shows the question, gives options A to D, tells me if I got it right, shows my score at the end. Thank you!

What you're building

Question 1 of 5: What is the capital of Japan?
  a) Seoul
  b) Beijing
  c) Tokyo
  d) Bangkok

Your answer: c
Correct!

---
You got 4 out of 5 correct.

What you'll need

  • Dictionaries — each question can be a dictionary with a question, options, and answer
  • Lists — all your questions live in a list you loop through
  • Control flow — looping through questions, branching on correct or incorrect
  • Functions — separating display logic from scoring keeps things readable
  • Output and input

Hints

Think about your data first. A list of dictionaries is the natural fit. Each dictionary holds one question: the question text, the answer options, and which answer is correct.

Keep score with a counter. One integer that starts at zero. Increment it when the answer is right. Print it at the end.

Comparing answers. The player types a letter. You're comparing it to the correct letter stored in your data. Make sure both are the same case before comparing.

Going further

Once the core quiz works:

  • Shuffle the questions. Use random.shuffle() so the order changes each run.
  • Show a summary. After the final score, list which questions the player got wrong and what the correct answers were.
  • High scores. Save the top scores to a file and display them at the start of each run. This requires the files chapter.