OCR J277 · Component 02 · 2.2.1
Variables, Constants and Assignment
Use a short top-to-bottom Python program to practise variables, constants and assignment. CodeQuest supplies the starting values; you change the statements that calculate and print the result.
- Estimated time
- 42 minutes
- Reward
- 10 XP
- Status
- Public Preview
Quest Briefing
Use a short top-to-bottom Python program to practise variables, constants and assignment. CodeQuest supplies the starting values; you change the statements that calculate and print the result.
By the end of this quest, you can...
Stage 2 · Learn
Understand the idea
Ready to inspect
Open each concept below to revise the key ideas.
Stage 2 · Learn · OCR J277 2.2.1
Variables, Constants and Assignment
Use a short top-to-bottom Python program to practise variables, constants and assignment. CodeQuest supplies the starting values; you change the statements that calculate and print the result.
What the code should demonstrate
This lesson demonstrates variables, constants and assignment using ordinary variables, selection, loops and output. Start with the supplied values, follow each statement from top to bottom, store the final answer in result and display it with print(result).
Worked example
Trace an analogous program before the assessed task
-
01Predict
Read the starting point first
Predict what the supplied values and statements will produce before inspecting the complete model.
Starting point# This is a different scenario from Guided practice. # Predict the output before reading the complete model. -
02TraceAnalogous transfer example
SERVICE_RATE = 0.1 base_fee = 30 service_fee = base_fee * SERVICE_RATE total_fee = base_fee + service_fee print(total_fee) -
03Run
Check your prediction
The starting values and program are shown above.
This lesson demonstrates variables, constants and assignment using ordinary variables, selection, loops and output. Start with the supplied values, follow each statement from top to bottom, store the final answer in result and display it with print(result).
Stage 3 · Apply
Use it in context
Ready to practise
Stage 3 · Apply · OCR J277 2.2.1
Code, check and repair
Complete an assisted task, solve a fresh task, then diagnose a faulty program.
Practical route
Three required coding rounds
- Read the fresh scenario and task contract for the current round.
- Use the supplied variables rather than copying the visible result.
- Compare the visible output with the expected result, then submit for CodeQuest to check other supplied values.
This practice run
Start fresh, keep your progress
Your saved lesson completion is unchanged. Each visit gives you a fresh copy. CodeQuest checks the shown case and additional supplied values.
0 / 3 rounds complete this visitRound 1 · Guided
Guided walkthrough
Understand it before you edit it
Hide guidance
Show guidance
Guided walkthrough
Understand it before you edit it
The task
Your job
Starting values
What each variable means
| Variable | Value | Plain-English meaning |
|---|
Read the program
What every line does
Your edit
Change one unfinished line
How you know it worked
- Inputs
- Required output
- First edit
Independent brief
Your task
For this example, the output should be .
Need help with the variable names?
| Variable | Value in this example | What it means |
|---|
Rules to remember
Expected:
Guided coding ready
Next step:
Program checks passed
A reusable version
Apply complete
Three coding rounds verified
You completed all three shown examples. Continue to Mission to build and test a reusable solution.
Stage 4 · Mission
Complete the challenge
Ready to prove
Stage 4 · Final challenge · OCR J277 2.2.1
Variables, Constants and Assignment verification
Complete one coding challenge, review your approach, then finish with an OCR-style written response.
Your mission
Mission: organise a simple game state
A game separates its fixed lives limit from the player's current lives.
Task: Keep MAX_LIVES as a fixed constant, store the supplied starting_lives in a changing variable and display that variable.
- 1 Run the shown example
- 2 Check your program and review choice
- 3 Write the exam response
Build · Practical coding
Create a program that works with the supplied values
Use the task card as your checklist. Run the example whenever you want to inspect the output.
Write only the required logic. CodeQuest has already loaded the example values shown in the task card—do not type their assignment lines again.
Progressive support Need a clue? 0 of 4 hints unlocked
Unlock one targeted hint only when you need it.
Review · Think like a developer
Check the quality of your approach
Select the advice that would make the program more dependable, then validate both parts together.
Mission workspace ready
Next step:
Final challenge complete
Practical and written mastery verified
You completed the coding mission, code review and OCR-style response in this visit.
Stage 5 · Complete
Review your progress
Lesson summary
Quick Check
Can you trace the program from its starting values to its displayed result?