Community resourceWorksheet

1CP2-CT-1.3 First programs, variables and constants

Part 3 of 7 · 1CP2-CT-1 · Programming foundations

The first Python worksheet of the course, turning an informal algorithm into working code.

Students will:

  • predict the exact output order of a short program
  • store values in named variables and read them back
  • choose between a variable and a constant, and name each conventionally
  • follow how a value changes as a program runs
  • write a short program of their own and explain an assignment statement

Inside: 9 explanation cells, 2 multiple-choice questions, 3 Python tasks, 2 fill-in-the-blanks cells and 2 written answers. 18 marks, about 45 minutes.

Series: 1CP2-CT-1 · Programming foundations, part 3 of 7.

Shared by Coding PathwayVerified teacher

  • 18 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 17 Aug 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

First programs, variables and constants

You already know that an algorithm is an ordered solution method. This worksheet introduces Python as one way to implement a short algorithm.

You will learn how to:

  • read and run print() instructions from top to bottom;
  • use literals and arithmetic expressions;
  • initialise and assign values to variables;
  • distinguish variables from constants;
  • follow value changes and write a short sequence program.

Every symbol is explained before you use it. User input and conversion belong to the next worksheet.

1. From algorithm to Python

An algorithm describes behaviour. Python expresses that behaviour using exact syntax.

Informal algorithm:

  1. Output the heading Plant total.
  2. Multiply 4 by 6 and output the result.
  3. Output Complete.

In a Python sequence, execution moves from the first line to the last line. print() displays the value inside its brackets. Text is placed inside quotation marks; numerical expressions are not.

Read this listing without executing it:

print("Plant total")
print(4 * 6)
print("Complete")
Multiple choice1 mark

Which option gives the exact output order?

  • A`Plant total`, then `24`, then `Complete`
  • B`Plant total`, then `4 * 6`, then `Complete`
  • C`24`, then `Plant total`, then `Complete`
  • D`Complete`, then `24`, then `Plant total`
Written answer1 mark

Explain why the second line outputs 24 rather than the characters 4 * 6.

Distinguish an unquoted arithmetic expression from text in quotation marks.

Students type their answer here.

2. Named storage

Named storage and assignmentscore5 → 8variable changeslives_remaining3meaningful identifierMAX_LIVES3constant stays fixedAssignment stores a value in a named place. A later assignment can replace a variable value.Uppercase names make intended constants easy to recognise.

A variable is a named place used to store a value that may change while a program runs. An identifier is the name used for that storage.

An assignment statement stores the value on the right of = in the name on the left. In Python, = means assign, not compare.

score = 5
score = score + 3

The first line initialises score by giving it its first value. The second assignment reads the current 5, adds 3 and stores the new value 8 back in score.

Worked example
score = 5
score = score + 3
print(score)
Fill in the blanks3 marks
The first assignment gives a variable its first value; this is label 1. A later label 2 can replace the stored value. The name score is an label 3.
  • assignment
  • constant
  • identifier
  • initialisation
  • output

3. Variables and constants

A constant is a named value intended not to change while the program runs. Pearson's Python subset uses uppercase names to show that intention:

MAX_PLACES = 30
places_booked = 18

MAX_PLACES is intended to remain 30. places_booked may change. Python does not technically prevent reassignment of an uppercase name, so using it correctly is a programming convention and a design decision.

Meaningful identifiers such as places_booked make code easier to read than vague names such as x. Identifiers cannot contain spaces, so an underscore can separate words.

Multiple choice1 mark

Which name most clearly follows the convention for a constant storing a fixed ticket price?

  • Ap
  • Bticket price
  • CTICKET_PRICE
  • Dticket_price

4. Follow value changes

Work down the program one line at a time and record the new value after each assignment:

items = 4
items = items + 3
items = items * 2
print(items)
Line completedStored value of items
items = 44
items = items + 37
items = items * 214

The output is therefore 14. The right side is evaluated using the old value before the new value is assigned.

Fill in the blanks2 marks
After points = 6, points stores 6. After points = points + 4, it stores label 1. After points = points * 3, it stores label 2.
  • 10
  • 18
  • 24
  • 30

5. Supported programming task

Amend the program below so it:

  1. initialises boxes to 5;
  2. initialises items_per_box to 6;
  3. assigns total the result of multiplying the two variables;
  4. outputs total.

The variable names are required because they communicate the algorithm clearly. The expected output is 30.

Coding task4 marks
boxes = 2
items_per_box = 4
total = boxes + items_per_box
print(total)

6. Independent programming task

Write a new sequence program for a hall layout. It must:

  1. create the constant ROWS with value 7;
  2. create the variable seats_per_row with value 8;
  3. calculate total_seats by multiplying those two named values;
  4. output total_seats.

Use the stated names. Your program should output 56. No keyboard input is needed.

Coding task4 marks

7. Explain an assignment

For score = score + 2, a precise explanation has two linked parts:

  • read the current value of score and add 2;
  • assign the result back to score, replacing its previous value.

Saying only “score equals score plus two” does not explain the change and can sound mathematically impossible.

Written answer2 marks

Explain what happens when Python executes stock = stock - 1.

State what is read and calculated, then what value is stored and where.

Students type their answer here.

Route forward

You have implemented sequence using print(), variables, constants, initialisation and assignment. Next you will examine the kinds of values programs store, accept keyboard input, convert that text and repair the first narrow runtime fault.