KS3 & GCSE Computing · Key Stage 3

Python input() and print() Explained for KS3 Computing

Learn how Python's input() and print() functions work for KS3 computing: reading user input, displaying output, and writing interactive programmes with worked examples.

Duke Harewood — author of AI Tutors for Key Stage 3Updated 4 min read

On this page

Short answer

Python's input() and print() functions are the two most important built-in tools for writing interactive programmes. input() pauses execution and waits for the user to type something; print() sends text or values to the screen. Together they transform a passive script into a conversation between the user and computer.

At a glance

Key stage
Key Stage 3
Subject
Computing
Type
How-to guide
For
Students
Read time
4 min
Last updated
21 October 2026

Where this fits

  1. Key Stage 3Years 7–9This article
  2. GCSEYears 10–11
This article is aimed at Key Stage 3 (Years 7–9), the stage before GCSE (Years 10–11).

Method at a glance

  1. Ask for a string input
  2. Ask for a numeric input
  3. Perform your calculation
  4. Display the result with print()
The 4 numbered steps in this article, in order.

What does the print() function do?

print() displays whatever you pass into it on the screen. Think of it as your programme's voice — the way it speaks back to you.

print("Hello, world!")          # outputs: Hello, world!
print(42)                       # outputs: 42
print("The answer is", 42)      # outputs: The answer is 42

You can print multiple items by separating them with commas. Python automatically adds a space between them. By default print() also adds a newline (moves to the next line) after each call.

Two useful keyword arguments:

  • sep=" " — changes the separator between items (default is a single space).
  • end="\n" — changes what is printed at the very end (default is a newline; use end="" to stay on the same line).
print("one", "two", "three", sep="-")   # outputs: one-two-three
print("Loading", end="")
print("...")                             # outputs: Loading...

What does the input() function do?

input() stops the programme, shows an optional prompt message, and then waits. The moment the user presses Enter, Python hands back everything they typed as a string.

name = input("What is your name? ")
print("Hello,", name)

The value returned is always a string — even if the user types a number. This is one of the most common sources of confusion at KS3.

How do you write an interactive programme in Python?

Follow these steps to build a simple interactive programme that greets the user and calculates their age at a target year:

  1. Ask for a string input. Use input() with a clear prompt so the user knows what to type. Store the result in a variable.
  2. Ask for a numeric input. Call input() again, then wrap it in int() or float() to convert the string to a number. Without this conversion, adding numbers will fail or give wrong results.
  3. Perform your calculation. Use the converted variables in an expression.
  4. Display the result with print(). Combine strings and values using commas or an f-string.
name = input("Enter your name: ")
birth_year = int(input("Enter your birth year: "))
target_year = 2040
age_in_target = target_year - birth_year
print(name, "will be", age_in_target, "in the year", target_year)

Why must you convert input() to a number?

input() always returns a string, even when the user types digits. If you try to do arithmetic with a string you will either get a TypeError or unexpected concatenation.

User types Without conversion With int()
"5" "5" + 3 → TypeError 5 + 3 → 8
"10" "10" * 2 → "1010" (string repeat) 10 * 2 → 20
"3.14" cannot add to float use float() → 3.14

The fix is to wrap input() in a type-conversion function:

  • int(input(...)) — for whole-number inputs (year, age, count).
  • float(input(...)) — for decimal inputs (height, price, temperature).

How do f-strings make print() output cleaner?

An f-string (formatted string literal) lets you embed variables directly inside a string using curly braces {}. This is often cleaner than using multiple commas.

name = input("Name: ")
score = int(input("Score: "))
print(f"Well done, {name}! Your score is {score}/100.")

F-strings also support basic formatting: {score:.2f} rounds a float to two decimal places, and {value:>10} right-aligns a value in a field of width 10.

What are common mistakes with input() and print()?

Mistake What goes wrong Fix
Forgetting to convert input() TypeError or string concatenation Wrap in int() or float()
No prompt in input() Programme appears frozen Always add a prompt string
Using print without parentheses SyntaxError in Python 3 Always write print(...)
Using + to combine string and int TypeError Use a comma or f-string instead

Frequently asked questions

Why does input() always return a string?

Python cannot know in advance whether the user intends to type a number, a name, or a sentence, so it plays it safe and returns everything as a string. Strings are the most general data type for human-entered text. It is then the programmer's responsibility to convert the input to the correct type using int(), float(), or bool() before using it in calculations.

What happens if the user types a word when the programme expects a number?

If you call int(input(...)) and the user types something that cannot be converted — such as "hello" — Python raises a ValueError and the programme crashes. At KS3 you are not yet expected to handle this elegantly, but at GCSE you would wrap the conversion in a try/except block to catch the error and ask the user to try again.

Can print() display the result of a calculation directly?

Yes. You can pass an entire expression inside print() without storing it first: print(3 + 4) outputs 7. Python evaluates the expression first, then prints the result. This is useful for quick checks during debugging.

What is the difference between print("hello") and print(hello)?

With quotation marks, print("hello") prints the literal text hello. Without quotation marks, print(hello) asks Python to find a variable called hello and print its value. If no such variable exists, you will get a NameError. This distinction between string literals and variable names catches many beginners off guard.


For Socratic KS3 tutoring and free GCSE flashcards, see aitutors.me.

Key terms

  • print()
  • newline
  • input()
  • prompt
  • string
  • Perform your calculation
  • TypeError
  • int(input(...))

Sources