Python - Output Variables
Output Variables
The Python print()
function is often used to output variables.
In the print()
function, you output multiple
variables, separated by a comma:
You can also use the +
operator to output
multiple variables:
Notice the space character after "Python "
and "is "
,
without them the result would be "Pythonisawesome".
For numbers, the +
character works as a mathematical operator:
In the print()
function, when you try to
combine a string and a number with the +
operator, Python will give you an error:
The best way to output multiple variables in the print()
function is to separate them with commas,
which even support different data types:
Exercise?What is this?
Test your skills by answering a few questions about the topics of this page
Consider the following code:print('Hello', 'World')
What will be the printed result?
Video: Python Output Variables
![Python Tutorial on YouTube](images/yt_logo_rgb_dark.png)
![Python Tutorial on YouTube](images/img_python_variables_output.png)