← Lesson
BitWithBite
Python · Quick Reference

Lesson 5 — Input & Output Cheat Sheet

Python
In one line: You've used print() since Lesson 1, but it has several powerful parameters that most beginners never discover. Understanding them makes your output cleaner and more professional.

Key Ideas

1print() — In Depth. You've used print() since Lesson 1, but it has several powerful parameters that most beginners never discover. Understanding them makes your output cleaner and more pr...
2input() — Getting User Data. The input() function pauses your program, displays a prompt, and waits for the user to type something and press Enter. It always returns a string — no matter what the ...
3Multiple Inputs & split(). Sometimes you want the user to enter several values at once, separated by spaces or commas. Python's .split() combined with input() makes this clean and efficient.
4Input Validation. Real programs can't trust users to type the right thing. Input validation means checking that the user's input is safe before you use it. Even a simple check with .isd...
5Building Interactive Programs. Combining print(), input(), variables, operators, and f-strings is all you need to build real interactive console programs. Let's look at three complete examples.

Code Examples

# Default print — sep=" ", end="\n" print("Python", "is", "great") # Python is great # Custom sep — change the separator print("Python", "is", "great", sep="-") # Python-is-great print("2025", "01", "15", sep="/") # 2025/01/15 print(1, 2, 3, ...
pi = 3.14159265 price = 1999999.5 percent = 0.875 # Decimal places with f-strings print(f"Pi (2dp): {pi:.2f}") # Pi (2dp): 3.14 print(f"Pi (5dp): {pi:.5f}") # Pi (5dp): 3.14159 # Thousands separator print(f"Price: {price:,....
# Basic input name = input("Enter your name: ") print(f"Hello, {name}!") # CRITICAL: input() ALWAYS returns a string! raw_age = input("Enter your age: ") print(type(raw_age)) # <class 'str'> — even if user typed 21 # Convert to int to do ari...