GCSE · Computer Science · Edexcel · Spec 1CP2
Input, processing and output
Type your name and the program greets you. Type your mate's name and it greets them instead. The code didn't change, so what did? Let's trace it, line by line.
Computer Science · Input and output
Run the name program twice
Three lines of code, two different users. Step through and watch what changes and what doesn't.
Predict before you press Next: if the user types Maya, what will line 3 put on the screen? And if the next user types Dev?
1 print("What is your name?")2 user = input()3 print(f"Hello {user}")
| run | line | user |
|---|---|---|
| 1 (Maya) | 1 |
Output
What is your name?
Step 1: Line 1 prints the question. Nobody has typed anything yet, so user has no value yet.
Press Next to run one line at a time, or use Back to compare run 1 with run 2.
Computer Science · Input and output
In, out, or error?
Pick a moment from running the name program, then choose which box it belongs in.
Still to sort
Input (0)
Data being sent into the program to be processed.
Where the line is: If the user is giving the program something, it's input. If the program is giving something back, it's not.
Expected output (0)
The result the programmer intended, such as a printed message.
Where the line is: It's information the program produces on purpose, not something that has gone wrong.
Error message (0)
What Python displays when something is wrong in the code.
Where the line is: It's still output, but it comes from a fault in the code rather than from the result you intended.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
How a program takes data in, keeps hold of it and sends information back out
What you need to know
- Input is data sent to a program to be processed. Output is the information produced as a result.
- Users give input at the keyboard by typing text and numbers. The computer answers with output, like displayed text or error messages.
- Input and output are not always a keyboard and a monitor.
- Neither happens automatically. The programmer has to specify exactly where and how input is taken and output is shown.
- Python runs code line by line, top to bottom, unless something changes the order, so output follows the order of the lines.
Have a goA sprinter's program has three print lines, written in this order: "Go!", then "Ready", then "Steady". Top to bottom, what does the screen show?
Go!, then Ready, then Steady.
Python runs the lines top to bottom, so the output follows the order they're written in, whatever order would make sense out loud.
- In Python, input() takes what the user enters, and you can store it in a variable, like user.
- print() displays output on the screen.
- Print a fixed name instead of the variable, and the output is that same name whatever the user enters.
Have a goAlex's last line is print("Hello Sam") and Alex is sure it greets whoever types in. Maya runs it and types Maya. What does she see?
Hello Sam
A fixed name gives the same output whatever the user enters. To greet Maya, the line has to print the variable holding what she typed.
- A string is text inside quotation marks. An f-string drops a variable's value into it using curly brackets.
Have a goA variable called colour holds what the user typed. Fill the gap so the colour appears: print(f"My favourite colour is ___")
{colour}
Curly brackets round the variable's name tell the f-string to put the variable's value in that spot.
- Python can produce expected output (the result intended) or error messages, which show when something is wrong in the code.
The big picture
Input is data sent into a program to be processed, and output is the information the program produces as a result. In Python, input() takes what the user types and can store it in a variable, and print() sends information back out to the screen. None of it happens by itself: the programmer writes the lines that say where input is taken and where and how output is shown.
Key points
Worked example
Problem
A program has these three lines: 1 print("Which team do you support?") 2 team = input() 3 print(f"Go {team}!") A user types Rovers. Write down exactly what the program outputs, in order.
⚠ Watch out
Assuming input and output happen on their own. They don't: you write the line that takes the input, and the line that prints the output.
Memory hook
Take it in, keep it in a variable, put it out. And nothing comes out until a print line says so.
Check yourself
Without looking back: what job does each of the three lines in the name program do, and why does the greeting change when a different name is typed?
Flashcards
(14)What is input?
What is output?
What can a user enter at the keyboard?
True or false: input and output always use a keyboard and a monitor.
Does a program show what the user typed without being told to?
In what order does Python run a program's lines?
What does the input function do in Python?
What does the print function do?
A greeting program always says Hello Sam, whoever types. What's wrong?
What is a string?
What does an f-string do?
Why use an f-string rather than joining text with +?
What is expected output?
What are error messages for?
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 Edexcel GCSE Computer Science topics
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)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 9 October 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.