Python Output: Printing Numbers and Mixing Values
Python Output Numbers
Printing Numbers
The print() function in Python is not limited to text. It can also be used to display numeric values directly.
When printing numbers, quotes are not required. Numbers are treated as numeric data, not text.
For example:
"print(7)"
"print(124)"
"print(9000)"
Each statement prints the number to the screen exactly as it is.
Performing Calculations in Print
Python allows arithmetic operations to be performed directly inside the print() function. This is useful for quickly viewing calculation results.
Examples include:
"print(10 + 15)"
"print(6 * 4)"
Python evaluates the expression first and then prints the final result.
Mixing Text and Numbers
Text and numbers can be displayed together in a single output. This can be done by separating values with commas inside the print() function.
For example:
"print("Score:", 88)"
"print("Level", 3, "completed")"
Python automatically formats the output so both text and numbers appear cleanly in one line.