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
- Key Stage 3Years 7–9This article
- GCSEYears 10–11
Method at a glance
- Ask for a string input
- Ask for a numeric input
- Perform your calculation
- Display the result with print()
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; useend=""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:
- Ask for a string input. Use
input()with a clear prompt so the user knows what to type. Store the result in a variable. - Ask for a numeric input. Call
input()again, then wrap it inint()orfloat()to convert the string to a number. Without this conversion, adding numbers will fail or give wrong results. - Perform your calculation. Use the converted variables in an expression.
- 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(...))