GCSE · Computer Science · OCR · Spec J277
Inputs, outputs, assignments
Type your name and a program says hello back. Feels like magic. It isn't: it's three short lines of Python, and the clever bit is one tiny = sign.
Computer Science · Programming
Follow one name through the program
Priya runs this program and types her name. Step through it and watch where her name goes: from the keyboard, into a variable, then back out onto the screen inside a message.
Before you press Next: once Priya has typed her name, what do you think line 3 will put on the screen?
1 print("What is your name?")2 user = input()3 print(f"Hello, {user}!")4 print(f"Nice to meet you, {user}.")
Variables
Output
What is your name?
Step 1: Line 1 runs first. print displays a message on the screen. The message is a string, and it's the computer's way of talking to Priya.
Press Next to run one step at a time. Watch the Variables panel on the right and the Output screen underneath.
Input or output?
Which way is it going?
Is each one input or output?
Still to sort
Input (0)
Data sent to a program to be processed.
Where the line is: If the user is sending it into the running program, it's input, usually typed on the keyboard.
Output (0)
Information produced by a computer system as a result of processing data.
Where the line is: If the computer is showing it to the user, it's output, even when it's not what you wanted to see.
Five moments from programs running. Sort each one, then read why it belongs there.
Predict, then check
Someone mixed up the last two lines of this race-starter program.
Jo runs it and types Jo. The lines are: print("What's your name?") / runner = input() / print("Ready...") / print(f"Go, {runner}!") / print("Steady..."). What do the printed messages show, top to bottom?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
How a program gets data from the user, keeps it in a variable, and shows it back on the screen.
What you need to know
- Input is data that's sent to a program so it can be processed.
- Output is information produced as a result of processing data. It's how a computer communicates with the user.
Have a goYour game console is running a quiz. You press a button to choose an answer, and the screen flashes "Correct!". Which bit was input, and which was output?
Pressing the button is input. "Correct!" is output.
Your button press is data going into the program to be processed. The message is information the computer produced afterwards. It's easy to call anything you see 'input' because you take it in, but it's output.
- Python has functions for both: input lets the user type, and print is one of the commonest ways to display output.
- You use the keyboard twice: to write the Python code, then to type input while it runs.
- In user = input(), whatever the user types is stored in the variable user.
- Storing a value in a variable is called assignment. It's what lets later lines use it.
Have a goYou want a program to keep the name of the user's favourite team, in a variable called team. Write the line.
team = input()
The variable goes on the left of the =, so the typed value is assigned to it. Writing input() on its own lets the user type, but nothing keeps the value for later.
- Strings can contain words, numbers and symbols, and they're how you write messages to the user.
- An f-string inserts a variable's value into a message: curly brackets go round the variable.
Have a goJay is certain that print(f"Hi {user}!") will show Hi {user}! on the screen. user holds Ali. What actually appears?
Hi Ali!
Jay has missed what the curly brackets do. In an f-string they say: put the value stored in this variable here. So the screen gets Ali, and the brackets never appear.
- Output isn't always what you meant. Error messages, such as syntax errors, are output too.
- Lines run in sequence, so output appears in the same order as the instructions.
The big picture
Input is data sent to a program to be processed; output is information produced as a result of processing data. In Python, input lets the user type on the keyboard, and assigning the value to a variable, such as user, lets later lines use it. print displays output, often as a string or an f-string, which inserts a variable's value using curly brackets. Output can also be an error message, such as a syntax error, and it appears in the same order as the instructions, because lines run in sequence.
Key points
Worked example
Problem
Write a short Python program that asks the user for their favourite food, keeps their answer, and then displays a message that includes it.
⚠ Watch out
Thinking the computer keeps whatever the user types automatically. It has to be assigned to a variable, as in user = input(), before later lines can use it. Close behind: leaving the curly brackets off in an f-string, so the screen shows the variable's name, not its value.
Memory hook
Type it, store it, show it. input lets the user type it, the variable stores it, and print with {curly brackets} shows it.
Check yourself
Cover the page. Can you say what input and output are, explain what the = does in user = input(), and say why a variable needs curly brackets round it in an f-string?
Flashcards
(13)What is input?
What is output?
Which Python function lets the user type information?
What does the print function do?
Give the two jobs the keyboard does in Python programming.
In user = input(), where does the value typed end up?
What is it called when a value is stored in a variable?
What can a string contain?
What is an f-string?
In an f-string, how do you mark where a variable's value goes?
Name the two kinds of output a Python program can produce when it runs.
Why does output appear in the order it does?
What is output for, from the user's point of view?
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 OCR GCSE Computer Science topics
How this lesson was checked. This OCR GCSE Computer Science (specification J277)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 3 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.