GCSE · Computer Science · Eduqas · Spec C500QS
Variables, operators, inputs, outputs and assignment
score = score + 1 looks impossible. So why does every game you've ever played rely on it?
Computer Science · Variables in Python
Be the computer: what is in the box now?
A user types -17. Call what each variable holds before the table shows it.
Step through the program. At each marked line, make your call first. Nothing is run here: every value is the lesson's, checked against Python.
score = 0score = 10score = score + 1answer = input("Whole number? ")n = int(answer)q = n // 5r = n % 5p = 2 ** 3neg = n < 0print(neg)
| score | answer | n | q | r | p | neg |
|---|---|---|---|---|---|---|
| 0 |
Step 1. score is created and given its first value, 0. This first row is worked for you.
Ask yourself: what is in each box right now, and what did this line put in it?
Computer Science · Data types
What kind of data is it?
Pick a value, then pick the data type it belongs to.
Still to sort
Integer (0)
A whole number
Where the line is: No decimal point and no speech marks. Add a decimal point and it becomes real; add speech marks and it becomes a string.
Real (float) (0)
A decimal number
Where the line is: Real numbers have a fractional part, even when it is a trailing .0.
Boolean (0)
True or false
Where the line is: Only two possible values: True and False.
String (0)
Text, which can include numbers and symbols
Where the line is: Anything in speech marks is text, even if the characters are digits. A string can be longer than one character.
Character (0)
A single character
Where the line is: One character only. More than one and it is a string.
Computer Science · Run it and read it
Read what Python says
This program should ask for two whole numbers and print their total. A tester types 1, then 2. Press Run, read what happens, then choose how to fix the flagged line.
- first = input("First number: ")
- print("Adding...")
- print(first + second)
The messages and outputs are what Python 3 gives for this exact code; other versions or languages may word them differently.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Trace a Python program line by line and always know what is in each box.
What you need to know
- A variable is a named place in memory. It holds one value at a time, and that value can change.
- Assignment stores a value: age = 22. Assign again and the old value is overwritten, so only the last value is kept.
Have a goA classmate says: "x = 5 and then x = 9 means x is 5 and 9 at the same time." What does x really hold, and what happened to the 5?
x holds 9. The 5 was overwritten and is gone.
A variable holds one value at a time, so a new assignment replaces the old value rather than sitting beside it.
- The right side of = is worked out first, then stored in the variable on the left, so score = score + 1 adds one.
- Input is data sent to a program to be processed; output is information produced by that processing. Neither is automatic: the programmer codes where and how.
- In Python, input() takes what the user types and print() displays it, but input() always returns a string, so cast with int() or float().
Have a goage = input() and the user types 8. Which word from today tells you what age holds, and which function would you wrap round input() to get a whole number?
A string (the text "8"); int().
input() always returns a string, even for digits, so you must cast it before treating it as a number.
- A data type is the kind of data: integer, real, Boolean, string or character. Speech marks make digits a string.
- Arithmetic operators are +, -, * and /, plus ** for powers. In Python, / always gives a real (float) result.
- // rounds the quotient down and % gives the matching remainder: 17 // 5 = 3 and 17 % 5 = 2.
Have a goUsing the idea that // rounds down and % gives the remainder, what are 20 // 6 and 20 % 6?
3 and 2.
6 fits into 20 three whole times (18), and 20 - 18 leaves 2. The whole-number part and the remainder fit together.
- Relational operators (==, !=, <, >, <=, >=) compare two values and give True or False. = stores, == tests.
- Use meaningful lowercase_with_underscore names; a constant should not change, and Python marks one only with CAPITALS.
The big picture
A variable is a named memory location holding one value at a time. Assignment works out the right side first, then overwrites the left. input() returns a string, so you cast it with int() or float(). Operators do arithmetic (including // and %) or compare values to give True or False, and = stores while == tests.
Key points
Worked example
Problem
A school trip has 23 students and each minibus seats 8. Write Python that stores how many minibuses will be full and how many students are left over, then say what each variable holds.
⚠ Watch out
Reading = as 'is equal to' from maths. In Python, = stores the result of the right-hand side in the variable on the left, and == is the symbol that tests whether two values are equal.
Memory hook
Right side first, then post it to the box on the left, and the old value is thrown out.
Check yourself
A variable called age holds 16. Which symbol would you use to test whether age is 16, which one would you use to change it to 17, and why can't you swap them?
Flashcards
(15)What is a variable?
What happens to the old value when you assign a new one?
In which order does an assignment run?
Do input and output happen automatically?
What type does Python's input() return?
Name the three Python casting functions.
List the five common data types.
Declaration or initialisation: which does Python use?
What causes a NameError?
How does a constant differ from a variable?
Does a CAPITALS name make a Python value unchangeable?
What do // and % give for -17 and 5?
What does a relational operator return?
What is the difference between = and ==?
What are the Python naming conventions for variables?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Eduqas GCSE Computer Science topics
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Selection in programs
- Sequence in programs
- String manipulation in code
- Subroutines with well-defined interfaces
- Typical, extreme and erroneous test data
- Understanding revised requirements
- Using a variety of data types
- Using testing outcomes to inform development
- Validation and verification routines in code
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 15 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.