Printing Text in Python
The print()
function is used to display text or other output in Python.
Basic Usage
print("Hello, world!")
This will show the text Hello, world!
on the screen.
Printing Variables
You can print the value of variables:
name = "Alice"
print(name)
Printing Multiple Items
Separate items with commas:
print("Name:", name)
Formatting Output
You can use f-strings for formatted output:
age = 30
print(f"{name} is {age} years old.")
Try using print()
with your own text and variables!
Next: Variables and Assignment → |
---|