Community resourceWorksheet
J277 2.2.1 Variables, constants, input and output
Part 1 of 7 · J277 2.2.1-2.2.2 · Programming fundamentals
The first programming worksheet: storing values, reading input and producing output.
Students will:
- assign values to variables and use them later
- explain the difference between a variable and a constant
- read input and produce readable output
- use naming that communicates intent
- write a short program from a stated requirement
Inside: 5 explanation cells, 3 runnable Python tasks, 2 multiple-choice questions, 1 fill-in-the-blanks cell and 2 written answers. 15 marks, about 45 minutes.
Series: J277 2.2.1-2.2.2 · Programming fundamentals, part 1 of 7.
Shared by Coding PathwayVerified teacher
- 13 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
- Updated 9 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Variables, constants, input and output
A variable is a named storage location whose value can change while a program runs. A constant is a value that should not change while the program runs. Python does not enforce constants, so programmers commonly use capital names such as VAT_RATE to communicate their intention.
The name given to a variable or constant is an identifier. A useful identifier describes the stored value, such as player_score, follows the language's naming rules, avoids reserved keywords and does not reuse the name of a built-in function such as print.
Which name is most suitable for a value that stores a player's changing score?
- Aplayer_score
- Bx
- CSCORE_LIMIT
- Dprint
Assignment, input and output
score = 10 assigns the value 10 to score. The assignment symbol does not mean “is permanently equal to”. A later statement can replace the stored value.
input() receives text from the user. print() produces output. When a numerical value is needed, the input usually must be converted, for example int(input("Age: ")).
The worked program below combines all four ideas. Before running it, identify the constant, predict which values the user must enter, and decide which variable changes when a different number of tickets is entered. Then run it with a name and ticket quantity of your choice.
ENTRY_PRICE = 6
name = input("Name: ")
tickets = int(input("Number of tickets: "))
total = tickets * ENTRY_PRICE
print(name, "owes £", total)
total = 0 is an example of label 3.- output
- constant
- assignment
- selection
- variable
Supported practice: league points
A league awards three points for every win. POINTS_PER_WIN is written as a constant because that rule is intended to stay fixed while the program runs. wins is a variable because a team can have a different number of wins.
Complete the program so that it calculates wins * POINTS_PER_WIN, stores the answer in points, and displays it. Seven wins should produce 21; another number of wins will also be checked.
POINTS_PER_WIN = 3
wins = 7
# 1. Calculate the points earned and store the result in points.
# 2. Display points.
After lives = 3 and then lives = lives - 1, what value is stored in lives?
- A3
- B2
- C1
- DAn error is always produced
Independent practice: reading record
Write a short program that asks for a student's name and the number of books they have read this month. A name is text, while the number of books must be converted to an integer.
Store the values in name and books, then display them in the exact sentence <name> has read <books> books. For example, inputs Aisha and 4 must produce Aisha has read 4 books.
# 1. Input the student's name and store it in name.
# 2. Input the number of books, cast it to an integer and store it in books.
# 3. Display a message containing name and books.
Explain why ENTRY_PRICE is more suitable as a constant than tickets in the worked program.
Compare whether each value is intended to change while this program runs.
Students type their answer here.
Correct the error in this statement and explain your answer: 10 = score.
State which side should contain the variable receiving the value.
Students type their answer here.
Review
Variables, constants, input, output and assignment are the building blocks of later programs. Read assignment from right to left: evaluate the expression on the right, then store the result in the variable on the left.
When an OCR question asks you to write code, use meaningful names, cast numerical input when needed and display the requested result. Minor differences in message wording are acceptable when the required data is clear.