How to print single and multiple variables in Python?

藏色散人
Release: 2019-03-26 15:32:29
Original
3761 people have browsed it

How to print single and multiple variables in Python?

Consider the following two Python code snippets from Python 2.x.

# Code 1 
print 1
# Output: 1
Copy after login
# Code 2 
print(1) 
# Output: 1
Copy after login

In the case of a single variable in Python 2. Group".

Example:

# Code 3 
print 1, 2
# Output: 1 2
Copy after login
# Code 4 
print (1, 2) 
# Output: (1, 2)
Copy after login

Note:
In Python 3.0, the print statement was changed to the print() function. Below is the equivalent code in Python 3.0.

# Equivalent codes in Python 3.0 
# (Produces same output) 
  
# Code 1: 
print(1) 
# Output: 1 
  
# Code 2 : 
print((1)) 
# Output: 1 
  
# Code 3: 
print(1, 2) 
# Output: 1 2 
  
# Code 4: 
print((1, 2)) 
# Output: (1, 2)
Copy after login

Related recommendations: "Python Tutorial"

This article is an introduction to how to print single and multiple variables in Python. I hope it will be useful to friends who need it. Helped!

The above is the detailed content of How to print single and multiple variables in Python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!