KS3 · Computer Science
Python: output, input and variables
Type Lucas into a program that says Hello Aisha and it still says Hello Aisha. Let's find out why, and how to make it listen.
Computer Science · Algorithms
Trace table — dry run the code
One tiny program, run twice. Step through it and follow the name: in through the keyboard, held in user, out onto the screen.
Ready when you are — step through one line at a time.
Predict, then check
Here is a program that looks like it greets whoever runs it. Does it?
A program prints the question "What is your name?", stores the answer with user = input(), then runs print("Hello Aisha"). Lucas sits down and types Lucas. What does the last line put on the screen?
Computer Science · Python
What happens when each line runs?
Pick a line, then pick what happens when it runs.
Still to sort
Syntax error (0)
A rule of Python's syntax is broken.
Where the line is: A missing closing bracket or a missing speech mark.
Stops with a different error (0)
An error message, but not a syntax error.
Where the line is: Python expects print in lowercase.
Runs but prints the wrong thing (0)
No error message, just not what you meant.
Where the line is: Nothing breaks, so Python has nothing to complain about.
Runs as intended (0)
Prints the name the user typed.
Every programming language has rules for syntax, and a program has to follow them so the language can understand it. But breaking a rule is only one way for a line to go wrong. Sort each line by what actually happens. Assume user already holds a name.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
What you need to know
- Input is data sent into a program to be processed, and output is information the computer gives back out.
- A keyboard is a common input device, and text or error messages on the screen are output.
- Python runs code line by line, top to bottom, unless something changes the order.
Have a goA program has three lines, from top to bottom: print("B"), print("A"), print("C"). What does the screen show, in order?
B, then A, then C.
Python follows the order of the instructions, top to bottom, not alphabetical order, unless something changes the order.
- print() sends text to the screen: lowercase print, then brackets, with the text inside speech marks.
Have a goDev types Print("Hi") with a capital P and says, "Python won't care about a capital letter." What do you tell Dev?
Python does care: print has to be lowercase, so Dev's line gives an error.
It feels like capitals are just decoration, but in Python the word print is written in lowercase.
- A string is a piece of text in speech marks, and it can hold words, numbers and symbols.
- input() takes what the user types, and you store it in a variable, like user = input().
- If print has a fixed name typed into it, it prints that name whatever the user enters. Use the variable holding the input.
- An f-string puts a variable's value into text using curly brackets: print(f"Hello {user}").
Have a goFill the gap so the line shows whatever name the user typed, which is held in user: print(f"Hello ___")
{user}
The curly brackets mark where the value goes, so the variable name sits inside them.
- You can store more than one input, each in its own variable, and use them all in one f-string.
- Every programming language has syntax rules, and a missing closing bracket or speech mark breaks them: a syntax error.
The big picture
Input gets data into a program and output gets information out. In Python, input() takes what the user types and stores it in a variable, and print() with an f-string can put it back on the screen, so the same code gives different output for different users. You will also learn to tell a syntax error from a line that runs but prints the wrong thing.
Key points
⚠ Watch out
Typing a name straight into the print line, like print("Hello Aisha"), and expecting it to greet whoever runs the program. It always prints that fixed name. The print statement has to use the variable that holds the input.
Memory hook
In through the keyboard, held in the variable, out through the curly brackets.
Check yourself
A program stores a typed answer in snack, then runs print(f"Yum, {snack}!"). Someone types toast. What appears, and what would appear without the curly brackets?
Flashcards
(14)What is input?
What is output?
Which device is a common way to give a Python program input?
In what order does Python run the lines of a program?
How do you write the print function correctly?
What is a string?
What does user = input() do?
Why does print("Hello Aisha") say Hello Aisha even when Lucas types his name?
What do the curly brackets do in print(f"Hello {user}")?
f-string or + : which is easier to read?
How do you store two different inputs?
Which two slips in a print line are syntax errors?
What happens if you write Print with a capital P?
What happens if you leave out the curly brackets in an f-string?
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 KS3 Computer Science topics
How this lesson was checked. This KS3 Computer Sciencelesson 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 8 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.