What Is Output for Variables in Python?

Python
name = "Alice" age = 25 print("Name:", name, "Age:", age) # Output: # Name: Alice Age: 25

In Python, outputting variables means displaying the value stored in a variable on the screen (console). This is usually done using the built-in print() function.

Printing a Single Variable

Assign a value to a variable, then use print() to display that value.

Python
x = "Python is awesome" print(x) # Output: # Python is awesome

Printing Multiple Variables

You can pass more than one variable to print() by separating them with commas.

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

Using commas automatically inserts spaces between values. 

Combining Variables and Text

1. Using Comma Separation

The simplest way to mix text and variables is by separating them with commas inside print():

Python
name = "Alice" age = 25 print("Name:", name, "Age:", age) # Output: # Name: Alice Age: 25


2. Using String Concatenation

You can join strings and variables with the + operator when working with strings:

Python
first = "Hello " last = "World!" print(first + last) # Output: # Hello World!

This method only works cleanly with strings; numbers must be converted with str() first. 

3. Using f-Strings (Formatted Strings)

f-strings provide a modern and readable way to include variable values within text:

Python
name = "Alice" age = 25 print(f"Name: {name}, Age: {age}") # Output: # Name: Alice, Age: 25

This works in Python 3.6 and later.

Numeric Output and Operators

When printing numeric variables, the + operator adds values mathematically rather than concatenating:

Python
x = 5 y = 10 print(x + y) # Output: # 15

If you try to concatenate a string and number directly, Python raises an error. Instead, use commas or formatting