Python Output
🖨️ Python Output (Print Function)
In Python, output is shown using the print() function. It displays text, numbers, variables, and results on the screen.
✅ Basic Print Example
Output:
🧩 Printing Numbers
Output:
🧩 Printing Variables
Output:
🧩 Printing Text with Variables
Method 1: Using Comma ,
Method 2: Using f-Strings (Recommended)
Method 3: Using format()
🧩 Printing Multiple Lines
🧩 Escape Characters
Escape characters allow printing special symbols.
| Escape Code | Meaning | Example |
|---|---|---|
\n |
New line | print("Hello\nWorld") |
\t |
Tab space | print("A\tB\tC") |
\" |
Double quote inside string | print("He said \"Hi\"") |
Example:
🧩 Changing the Default End (end parameter)
By default, print ends with a newline. You can change it:
Output:
🧩 Changing Separator (sep parameter)
Output:
🎯 Summary
| Feature | Example |
|---|---|
| Print text | print("Hello") |
| Print numbers | print(100) |
| Print variable | print(x) |
| Format message | print(f"Value is {x}") |
| New line | \n |
| Custom end | print("Hello", end="***") |
| Separator | print(a, b, sep=",") |
