What is Print?
The print() function is how your program talks to you! It displays text on the screen.
Printing Text
To print text, put it inside quotes and wrap it with print():
python
print("Hello!")
This shows:
text
Hello!
You can use single quotes too:
python
print('Hello!')
Printing Numbers
You can print numbers without quotes:
python
print(42)
print(3.14)
Printing Multiple Things
Use commas to print several things on one line. Python adds spaces between them:
python
print("I am", 10, "years old")
Output:
text
I am 10 years old
Multiple Lines
Each print() starts a new line:
python
print("Line 1")
print("Line 2")
print("Line 3")
Blank Lines
Call print() with nothing inside to print a blank line:
python
print("Top")
print()
print("Bottom")
Output:
text
Top Bottom
Now let's practice!