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

user=nothing stored yet

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.

1 / 5

Press Next to run one step at a time. Watch the Variables panel on the right and the Output screen underneath.

Step 1 of 5: 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..

Watch out: Typing the name isn't enough on its own. It's the user = part that keeps it, so lines 3 and 4 can use it.

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.

5 of 5 still to sort.

Five moments from programs running. Sort each one, then read why it belongs there.

Assignment

Does the computer just remember?

Sam is looking at the line user = input(). He says: "Why bother with the user = bit? I've typed my name. Surely the computer just remembers it."

Which is closest to what you think right now?
How sure are you?

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?

Find the faulty line

Where did the name go?

Ada wants her program to greet the user by name. She runs it and types Ada, but the screen shows: Nice to meet you, user! Which line stops her name appearing?

Ada's program — which line goes wrong?

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

1Input is data sent to a program to be processed; output is information produced by a computer system as a result of processing data.
2The input function lets a user type information on the keyboard; assigning the value to a variable, as in user = input(), lets the program use it later.
3print is one of the most common ways to display output, and strings (words, numbers and symbols) make up the messages.
4An f-string inserts a variable's value into a message, with curly brackets round the variable, for example {user}.
5Lines run in sequence, so output appears in the order of the instructions, and output can be the expected result or an error message such as a syntax error.

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?
Data that is sent to a program to be processed.
What is output?
Information produced by a computer system as a result of processing data.
Which Python function lets the user type information?
The input function.
What does the print function do?
Displays information on the screen. It's one of the most common ways to display output.
Give the two jobs the keyboard does in Python programming.
Writing the Python code, and providing input when the program runs.
In user = input(), where does the value typed end up?
Stored in the variable user, so it can be used later in the program.
What is it called when a value is stored in a variable?
Assignment.
What can a string contain?
Words, numbers and symbols.
What is an f-string?
A formatted string: it inserts text directly into another string to format the output.
In an f-string, how do you mark where a variable's value goes?
Put curly brackets round the variable, for example {user}.
Name the two kinds of output a Python program can produce when it runs.
The expected output (the result intended, such as printed messages) or error messages, such as syntax errors.
Why does output appear in the order it does?
The lines of a program run in sequence, so output follows the order of the instructions.
What is output for, from the user's point of view?
It's how a computer communicates information to the user.

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 posted

More OCR GCSE Computer Science topics

See the full OCR Computer Science curriculum →

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.