Notes / Python / Input & Output

Input & Output in Python — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Input & Output Python's print() function outputs text to the console, and input() reads a line of text typed by the user.

Syntax

syntax
print(value1, value2, ...)
variable = input("prompt")

Example

py
age_text = input("Enter your age: ")
age = int(age_text)
print("You are", age, "years old.")

Output

outputEnter your age: 20 You are 20 years old.

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview "Why does input() always return a string?" — because Python can't know in advance if the user meant to type a number, a word, or something else; you decide the intended type.
Back to notes Read full lesson →