Back to Python Notes
Topic #12

Output Variables

Combining variables with text in print() output is a daily task in Python. Learn string concatenation and commas to format messages cleanly.


Output Variables

The print() function is often used to output variables.

Example

x = "Python is awesome"
print(x)

In the print() function, you output multiple variables, separated by a comma:

Example

  x = "Python"
y = "is"
z = "awesome"
print(x, y, z)

You can also use the + operator to output multiple variables:

Example

x = "Python "
y = "is "
z = "awesome"
print(x
  + y + z)

Note: Notice the space character after "Python " and "is ", without them the result would be "Pythonisawesome".

For numbers, the + character works as a mathematical operator:

Example

x = 5
y = 10
print(x + y)

In the print() function, when you try to combine a string and a number with the + operator, Python will give you an error:

Example

  x = 5
y = "John"
print(x + y)

The best way to output multiple variables in the print() function is to separate them with commas, which even support different data types:

Example

x = 5
y = "John"
print(x, y)

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Output Variables – FAQs

Quick answers about learning Output Variables in Python.

This free note from Coding Now Tech Institute explains Output Variables in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Output Variables, is 100% free with no signup required.
With focused practice, most students grasp Output Variables in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now