AssignmentsWeek 02 · Decisions and structureChallenge — mini quiz game
wk02.p10Practice exerciseWeek 02 · Decisions and structureOpen · due stretch challenge

Challenge — mini quiz game

Run a short quiz from two parallel lists — questions and answers — and score it. The purest combiner: a list, indexing, a for loop, a counter, and a comparison, no new tools at all.

What you'll build

Run a short quiz from two parallel lists — questions and answers — and score it. The purest combiner: a list, indexing, a for loop, a counter, and a comparison, no new tools at all.

Requirements

The must-do parts. If any are missing, we'll ask you to take another pass.

  1. Store at least four questions in one list and their answers in a second list, lined up position-for-position.
  2. Walk the questions with a for loop, keeping an index (i = 0, then i = i + 1 each round) so you can reach the matching answer with answers[i].
  3. Ask each question with input, and compare the reply to the correct answer.
  4. Keep a score counter that starts at 0 and goes up by one for each correct answer.
  5. At the end, print the score out of the total using len() — e.g. You scored 3 out of 4.
Bonus, if you're feeling brave
  • Make answers case-insensitive so Accra and accra both count. Look up .lower().
  • Tell the player after each question whether they were right or wrong, and show the correct answer when they miss.
  • Add a passing line at the end — 50% or more prints You passed., otherwise Try again.

Examples

What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.

Example cell runs
Capital of Ghana? accra
2 + 2 = ? 4
Largest planet in our solar system? mars
Type the word 'python': python
You scored 3 out of 4.

Where to start

Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.

# Mini quiz game
questions = [
    "Capital of Ghana? ",
    "2 + 2 = ? ",
    "Largest planet in our solar system? ",
    "Type the word 'python': ",
]
answers = ["accra", "4", "jupiter", "python"]

score = 0
i = 0

# TODO: use a for loop over questions, keeping i in step,
#       compare the reply to answers[i], and add to score when it matches.
# After the loop, print the score out of len(questions).

How we'll grade it

Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.

CheckWhat we look forPt
It runsAsks every question in order and prints a final score without crashing.1
Lists stay lined upEach question is checked against its own answer via the index — answers don't drift out of step.1
Score is correctThe final score matches the number of right answers. Getting all of them right scores the full total.1
Score out of totalThe total comes from `len()` of the list, so adding a question updates it automatically.1
Ready?
Hand it in
You can submit a draft and revise later if you're not done.
Begin submission →