BBampaa

Lessons › Python

Python lesson

print()

Python runs each line from top to bottom. The quotes aren't shown: they only tell Python where the text starts and ends. With numbers, the maths is worked out first, so 35 + 15 shows 50.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

print() shows whatever you put inside its brackets. Text goes in quotes. Numbers don't:

print("Hello, Lagos")
print(35)
print(35 + 15)

Output:

Hello, Lagos
35
50

Key points

print(...)Shows what's inside the brackets in the output.
"Hello"Text goes inside quotes. The quotes themselves aren't shown.
print(35 + 15)Numbers need no quotes, and the maths is done first: this shows 50.

Put together: print("Earbuds") shows text, and print(2 * 35) shows 70.

Practice

Try each one in your head first, then open the answer.

1. Build a line that shows the text Earbuds.
print("Earbuds")
2. Build a line that shows the answer to 12 times 8.
print(12 * 8)
3. Show the word Welcome.
print("Welcome")
4. Show the answer to 35 times 4.
print(35 * 4)
5. Show two lines: first the word Total, then the answer to 96 + 120.
print("Total")
print(96 + 120)

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed