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.
- Store at least four questions in one list and their answers in a second list, lined up position-for-position.
- Walk the questions with a
forloop, keeping an index (i = 0, theni = i + 1each round) so you can reach the matching answer withanswers[i]. - Ask each question with
input, and compare the reply to the correct answer. - Keep a
scorecounter that starts at 0 and goes up by one for each correct answer. - 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
Accraandaccraboth 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., otherwiseTry 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.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Asks every question in order and prints a final score without crashing. | 1 |
| Lists stay lined up | Each question is checked against its own answer via the index — answers don't drift out of step. | 1 |
| Score is correct | The final score matches the number of right answers. Getting all of them right scores the full total. | 1 |
| Score out of total | The total comes from `len()` of the list, so adding a question updates it automatically. | 1 |