lesson 3.1.6 mini-project - the quiz
Everyone likes a quiz.

Welcome to the grand finale of your programming boot camp! Today, you are stepping into the shoes of a full-fledged Software DeveloperI have no idea what this means. You've mastered the tools—variablesI have no idea what this means, inputPutting data into a computer system, selectionI have no idea what this means, and iterationI have no idea what this means - and now it's time to build something real. You will design and code your very own interactive Quiz Game to challenge your friends. But writing code that works is only half the battle; today you will also learn the art of refactoringI have no idea what this means - cleaning up your code to make it readable, professional, and efficient. Let's get coding!
Learning Outcomes
The Building Blocks (Factual Knowledge)
The Connections and Theories (Conceptual Knowledge)
The Skills and Methods (Procedural Outcomes)
Recall that a variableA variable is a temporary value held in RAM and assigned a name / identifier. The value of the variable can change during program execution. is a named container for storing data values.
State the correct syntaxThe 'grammar' of a computer programming language. for selectionI have no idea what this means (if/elif/else) and iterationI have no idea what this means (while/for) in Python.
Define refactoringI have no idea what this means as the process of restructuring code to improve readability without changing its function.
The Connections and Theories (Conceptual Knowledge)
Explain how sequenceA programming construct where a set of instructions is executed in order, selectionI have no idea what this means, and iterationI have no idea what this means combine to create complex program flow.
Analyse the importance of code readabilityI have no idea what this means, including the use of commentsI have no idea what this means and meaningful identifiers, for collaboration and maintenance.
Distinguish between working code and quality code.
The Skills and Methods (Procedural Outcomes)
Create a robust multi-question quiz program that combines user input, scoring, and conditional logic.
Apply refactoringI have no idea what this means techniques to improve a piece of "messy" code by renaming variables and adding comments.
Debug syntax and logic errors within a larger project context.
Digital Skill Focus: C.1.1 Core Skills: Develop touch-typing skills to improve speed and accuracy of syntax entry within an IDE.
The Master Plan: Decomposition
Before we write a single line of code, we need a plan. Professional Software DevelopersI have no idea what this means don't just start typing; they use computational thinkingA way of thinking where a problem and a solution is expressed in such a way that a computer could be given the instructions to solve the problem., specifically decompositionTo break down into smaller, more manageable parts in order to make a problem easier to solve. (decompose, decomposing), to break the big problem ("Build a Quiz") into small, manageable steps.
Think about what a quiz game actually needs:
1
Setup: A way to store the score (a variableA variable is a temporary value held in RAM and assigned a name / identifier. The value of the variable can change during program execution.).
2
The Question: Asking the user for inputPutting data into a computer system.
3
The Logic: Checking if the answer is correct (selectionI have no idea what this means).
4
The Feedback: Telling the user if they won or lost.
5
The Score: Adding points if they are right.
By solving just one question first, we create a pattern (an algorithmA 'recipe' or sequence of 'unambiguous' instructions for solving a problem.) that we can repeat for every other question!

Task 1 Build-A-Quiz Workshop
1
Get Organised!
Open Thonny.
Copy the Starter Code below into your editor.
print("--- THE ULTIMATE QUIZ ---")
score = 0 # This variable stores the player's points
# QUESTION 1
answer1 = input("What is the capital of France? ")
if answer1 == "Paris":
print("Correct! +1 Point")
score = score + 1 # Add to score
else:
print("Wrong! The answer was Paris.")
print("Current Score:", score)
# --- ADD QUESTION 2 HERE ---
# --- ADD QUESTION 3 HERE ---
print("--- GAME OVER ---")
print("Final Score:", score)
2
Plan Your Questions
Decide on 3 questions you want to ask. Keep the answers simple (one word is best!).
3
Your Mission
1
Run the code to see how Question 1 works.
2
Copy the code for Question 1 (from
answer1 = down to the print score line).3
Paste it under the
# ADD QUESTION 2 HERE comment.4
Modify it:
Change the variable name to
answer2.Change the question text.
Change the correct answer in the
if line.5
Repeat for Question 3!
4
Try it on your friend
Run the script and collapse the script window in Thonny so that your friend can't see the answers! See how they do!
Outcome: I have created a working quiz game using variables, input, and selection.

Code Quality: Refactoring
Congratulations, you have a working program! But is it a good program?
In the professional world, code is read by humans more often than it is run by computers. RefactoringI have no idea what this means is the process of cleaning up code to make it easier to read and maintain, without changing what it actually does.
Imagine trying to read a book with no punctuation, no paragraphs, and characters named "a", "b", and "c". Nightmare, right? Code is the same.
Key Refactoring Rules:
Meaningful Names: Use
player_score instead of s. Use user_age instead of x.Comments: Use
# to leave notes explaining why your code does something.Whitespace: Use blank lines to separate different sections (like paragraphs in a story).

Task 2 Code Detectives: The Cleanup Job
1
The Messy Code
Copy this code into a new script in Thonny:
n = input("Enter n: ")
a = int(input("Enter a: "))
# calc
y = 2025 - a
print("Hi", n)
print("You were born in", y)
2
The Job
Refactor the code to make it professional:
1
Rename variable
n to name.2
Rename variable
a to age.3
Rename variable
y to year.4
Fix the prompts
"Enter n: " is ambiguous! Change it to "What is your name? "."Enter a: " is ambiguous! Change it to "What is your age in whole years? ".5
Add Comments: Replace
# calc with a comment that actually explains the maths (e.g., # Calculate birth year).3
Run it to make sure it still works!
Run the code you have refactored to make sure it still works ok. If not, try and fix it! If it all goes horribly wrong, you can always start again with the starter code from step 1.
Outcome: I have refactored code to improve its readability and maintainability.

Out of Lesson Learning
Last modified: January 8th, 2026
