GCSE · Computer Science · AQA · Spec 8525

Keyboard input

Ever seen a program just sit there, cursor blinking? It isn't broken. It's waiting for you, and it's about to keep whatever you type.

Computer Science · Algorithms

Trace table — dry run the code

Aisha runs this little quiz. Step through it and keep an eye on each USERINPUT line: the program freezes there until she types.

1OUTPUT "What is your name?"
2name ← USERINPUT
3OUTPUT "Hi " + name + "!"
4OUTPUT "Closest planet to the Sun?"
5answer ← USERINPUT
6IF answer = "Mercury" THEN
7 OUTPUT "Correct, " + name + "!"
8ELSE
9 OUTPUT "Nearly, " + name + ". It's Mercury."
10ENDIF
name
answer
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

Predict, then check

Two users, one program.

A program has three lines: OUTPUT "Favourite food?", then food ← USERINPUT, then OUTPUT "Mmm, " + food + "!". Sam runs it and types pizza, and the screen ends with Mmm, pizza! Then Jo runs exactly the same program and types sushi. What does Jo's last line say?

Find the bug

Where did the pet's name go?

Kai wants a program that asks for a pet's name and then says hello to the pet. When it runs, the program waits and the user types Biscuit, but the greeting never says Biscuit. Which line goes wrong?

Kai's program — which line goes wrong?

Your turn

Build a program that asks and replies

Write a program that asks for the user's name and favourite colour, then replies using both. Choose each missing line.

  1. OUTPUT "What is your name?"
  2. missing step
Which line is step 2?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

The line that stops, waits for you, and keeps what you typed

What you need to know

  • An input line makes the program pause until the user types something and presses Enter.
  • The arrow ← means 'store in': name ← USERINPUT puts whatever was typed into the variable name.
  • Have a goLook at mood ← USERINPUT. Which bit is the variable, and which bit actually fetches the typing?

    mood is the variable; USERINPUT fetches what's typed (and ← stores it in mood).

    It's tempting to read the line left to right as 'mood, then input', but the work happens on the right: the typing is fetched, then the arrow stores it in mood.

  • Python writes the same idea as name = input().
  • Later lines get the typed value by naming the variable, outside any quotation marks.
  • Have a goZara typed Zara into name. Her mate swears OUTPUT "Hi name" will greet her properly. What does the screen actually say?

    Hi name

    Inside quotation marks, name is just text to print. To get Zara, the variable has to sit outside the quotes: OUTPUT "Hi " + name.

  • The value stays in that variable until the program changes it. Storing in a different variable leaves it alone.
  • The programmer writes the input line; the user supplies the value each time the program runs.
  • So one program can give different users different results, with not a single character of code changed.
  • Put an OUTPUT prompt before the input, so the user knows what to type.
  • Have a goKofi's program begins with team ← USERINPUT and has no line before it. What does the user see while it waits?

    Nothing: a blank screen with no question on it.

    An input line waits but shows nothing itself. Only an OUTPUT prompt placed before it tells the user what the program wants.

  • If the input isn't stored in a variable, the program still waits, but what was typed is lost.

The big picture

Keyboard input lets a program get a value from the user while it is running. At an input line the program stops and waits until the user types something and presses Enter. What they typed is stored in a variable, and any later line can use it by naming that variable. The value comes from the user, not from the code, so the same program can behave differently for different people.

Key points

1Input means pause, then store.
2The value is typed while the program runs; it is not written in the code.
3Prompt first, then input, then use.
4An input that isn't stored in a variable is lost.

Worked example

Problem

A program runs these three lines: OUTPUT "Which town do you live in?", then town ← USERINPUT, then OUTPUT "I hear " + town + " is lovely." The user types Leeds. What does the program output, in order?

⚠ Watch out

Thinking the input line shows something, or that the programmer decides its value. It's an easy mix-up, because the prompt and the input sit right next to each other. But OUTPUT shows; USERINPUT collects. The value in town ← USERINPUT isn't known until someone types it.

🧠

Memory hook

Pause, store, use. Picture a waiter: they stop at your table and wait, write your order on their pad (the variable), and the kitchen cooks from the pad. The order comes from you, not from whoever printed the menu.

✓

Check yourself

Without looking back: a program contains the line colour ← USERINPUT. What happens when the program reaches this line, and how can a later line use what the user typed?

Flashcards

(7)
What does a program do when it reaches an input line?
It pauses and waits until the user types something and presses Enter.
In city ← USERINPUT, where does the typed value go?
Into the variable city, where later lines can use it.
How does a later line use what the user typed?
By naming the variable: OUTPUT "Hello " + name shows whatever is stored in name.
Who decides the value stored by name ← USERINPUT?
The user, while the program runs. The programmer only writes the line.
Why put an OUTPUT prompt before an input line?
So the user knows the program is waiting and what they should type.
What happens to typed input that isn't stored in a variable?
It is lost, so no later line can use it.
Why do programs take input at all?
So the same code can work with different values on each run: different users, different results.

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

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)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 29 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.