Skip to main content

Print Numbers

Numbers work with print() too, and they don't need the quotes that text does. The same function can also work out math for you.

Print numbers

Prompt
Print three numbers on separate lines: 3, 358, and 50000.
Output: complete Python program

Math in print

Put a calculation inside print() and it displays the result:

Prompt
Print the results of two math operations: 3 + 3 and 2 * 5.
Output: complete Python program

Mix Text and Numbers

To show text and numbers together in one output, put a comma between them.

Example

Prompt
Print a sentence that combines text and a number using commas in the print function: "I am", 35, "years old."
Output: complete Python program