In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the "definition, use and output of variables in python" related knowledge, in the actual case operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
1. Define variable
Enter:
# Filename: var.py
I = 5
Print (I)
I = I + 1
Print (I)
S =''This is a multi-line string. This is the second line.'''
Print (s)
Output:
five
six
This is a multi-line string.
This is the second line.
Explanation:
It is preceded by the name of the variable, the code name of a number or a paragraph of characters.
Assignment assigns the latter to the preceding variable through the "=".
(order before and after)
two。 Abbreviation of variable operation
Enter:
A = 2; a * = 3
A = 2; a = a * 3
Output:
six
six
Explanation:
A shorthand method when the same variable appears on both sides of the equal sign.
A=a+3 is equivalent to axiomatic 3.
3. Variable operation output
Enter:
#! / usr/bin/python # Filename: expression.py
Length = 5
Breadth = 2
Area = length * breadth
Print ('Area is', area)
Print ('Perimeter is', 2 * (length + breadth))
Output:
Area is 10
Perimeter is 14
Explanation:
Assign the value first, and then calculate it.
This is the end of the definition, use and output of variables in python. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.