Print Single and Multiple variable in Python?

ProgrammingPythonServer Side Programming

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 −


print(5) print((10))



Print Multiple Variables in Python

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


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


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 −


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


5 10 15 10 20 30 40 50
Updated on 11-Aug-2022 11:55:16