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}")
runlineuser
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.

1 / 6

Press Next to run one line at a time, or use Back to compare run 1 with run 2.

Step 1 of 6: Line 1 prints the question. Nobody has typed anything yet, so user has no value yet..

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.

5 of 5 still to sort.

Watch out: A keyboard and a monitor are the familiar pair, but input and output are not always through a keyboard and monitor. Decide by asking: is data going in, or is information coming out?

Computer Science · Input and output

What happens next?

A program has just run the line user = input(), and the user typed Maya.

Which idea is closest to what you think happens next?
How sure are you?

Computer Science · Input and output

Find the line that lets the user down

This program should greet whoever types their name. Maya runs it and types Maya, but the screen says Hello Sam. Which line is the problem?

A pupil's program — which line goes wrong?

Two ways to build a message

f-stringvsJoining with +

First, the building block. A string is text inside quotation marks. It can hold words, numbers and symbols, and it's what a program uses to output messages.

Focus

The code

f-string

print(f"Hello {user}")

Joining with +

print("Hello " + user)

The insight

Both put the value stored in user into the message. They just do it differently.

How the value gets in

f-string

Curly brackets round the variable's name, inside the string

Joining with +

The + operator joins the text and the variable together

Reading it back

f-string

Reads almost like the message the user will see

Joining with +

Reads as separate pieces stuck together

Computer Science · Have a go

Your turn: write it, then mark it

Write a short Python program that asks the user for their favourite food, stores what they type in a variable, and outputs a sentence containing that food using an f-string. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1Input is data going in. Output is information coming out.
2Neither happens automatically: you write the line that takes input and the line that prints output.
3user = input() stores what the user types. print(f"Hello {user}") outputs the stored value.
4Print the variable, not a fixed name, or the output never changes.
5Output comes in two types here: expected output and error messages.

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?
Data sent to a program to be processed. Input gets data into the computer.
What is output?
Information produced by a computer system as a result of processing data. Output gets information out.
What can a user enter at the keyboard?
Text and numbers.
True or false: input and output always use a keyboard and a monitor.
False. Input and output are not always through a keyboard and monitor.
Does a program show what the user typed without being told to?
No. Input and output don't happen automatically. The programmer specifies exactly where and how they are handled.
In what order does Python run a program's lines?
Line by line, top to bottom, unless something changes the order (like repeating steps or making decisions). So output appears in the same order as the instructions.
What does the input function do in Python?
Takes the information a user enters. The value can be stored in a variable, e.g. user = input()
What does the print function do?
Displays output on the screen.
A greeting program always says Hello Sam, whoever types. What's wrong?
It prints a fixed name instead of the value held in the input variable.
What is a string?
A piece of text inside quotation marks. It can contain words, numbers and symbols, and is used to output messages.
What does an f-string do?
Inserts a variable's value into another string using curly brackets, e.g. print(f"Hello {user}").
Why use an f-string rather than joining text with +?
F-strings are easier to read and more straightforward.
What is expected output?
The result the programmer intended, such as printed messages.
What are error messages for?
Python displays them when something is wrong in the code, such as a syntax error, to help the programmer fix it.

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 Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

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.