
Python Output / Print
Print Text
You have already learned that you can use the print() function to display text or output values:
print("Hello World!")You can use the print() function as many times as you want. Each call prints on a new line by default:
print("Hello World!")
print("I am learning Python.")
print("It is awesome!")Double Quotes
Text in Python must be inside quotes. You can use either " double quotes or ' single quotes:
print("This will work!")
print('This will also work!')If you forget to put the text inside quotes, Python will give an error:
print(This will cause an error)
Result:
Print Without a New Line
By default, the print() function ends with a new line.
If you want to print multiple words on the same line, you can use the end parameter:
print("Hello World!", end=" ")
print("I will print on the same line.")Note that we add a space after end=" " for better readability.
Python Output Numbers
Print Numbers
You can also use the print() function to display numbers:
However, unlike text, we don't put numbers inside double quotes:
print(3) print(358) print(50000)
You can also do math inside the print() function:
print(3 + 3) print(2 * 5)
Mix Text and Numbers
You can combine text and numbers in one output by separating them with a comma:
print("I am", 35, "years old.")