Print Single and Multiple variable in Python?


To easily display single and multiple variables in Python, use the print() statement. For multiple variables, use the comma operators.

Variables are reserved memory locations to store values. It means that when you create a variable, you reserve some space in the memory.

Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to the variables, you can store integers, decimals or characters in these variables.

Print Single Variable in Python

To display a single variable, simply use the print() method −

Example

print(5) print((10))

Output

5
10

Print Multiple Variables in Python

To display multiple variables, simply use the print() method. Set the variables using the comma operator −

Example

print(5, 10, 15) print((10, 20, 30, 40, 50))

Output

5 10 15
(10, 20, 30, 40, 50)

Print multiple variables on the same line using the end parameter

To display multiple variables, use the print() method. To set the variables from multiple print() in a single line, use the end operator −

Example

print(5, 10, 15, end=" ") print(10, 20, 30, 40, 50)

Output

5 10 15 10 20 30 40 50

Updated on: 26-Oct-2023

24K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements