Print Single and Multiple variable in Python

Course Curriculum

Print Single and Multiple variable in Python

Print Single and Multiple variable in Python

In Python 3.X, the print statement is written as print() function. Below code in Python 3.X that shows the process of printing values in Python.

Example 1: Printing Single value

Python3

# Equivalent codes in Python 3.0
# (Produces same output)

# Code 1:
print(1)

# Code 2 :
print((1))
Output:

1
1
Example 2: Printing multiple values

Python3

# Code 1:
print(1, 2)

# Code 2:
print((1, 2))

# Code 3:
# printing on the same line
# for printing on the same line use end parameters of the print function
# end takes the values which is priting at the end of the output.
print(1, end=" ")
print(2)
Output:

1 2
(1, 2)

Byte Objects vs String in Python (Prev Lesson)
(Next Lesson) Swap two variables in one line