In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to realize the assignment statement and basic input and output of python". In daily operation, I believe that many people have doubts about how to realize the assignment statement and basic input and output of python. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to realize the assignment statement and basic input and output of python". Next, please follow the editor to study!
A sequential structure executes code in the order of statements, that is, An is executed first, and then B, which usually contains assignment statements, input and output function calls.
The assignment statement assigns a value directly:
The "=" in python is the assignment operator. Variable is assigned for the first time, the type and value are obtained at the same time, and the type is determined according to the value, and the value is assigned by reference
Incremental assignment:
Chain assignment:
Multiple assignments:
The essence of multiple assignment is tuple packing (tuple packing) and sequence unpacking (sequence unpacking).
Grammatical sugar:
Using multiple assignments for variable exchange
Basic input: input () function:
X=input (['input prompt'])
Because the return type of the input () function is str, it is sometimes necessary to use functions such as int () and float () to convert the input data to the desired type.
Eval () function:
Regardless of entering data of type int or float, the eval () function can evaluate them as valid python expressions.
If you want to enter a set of data or a more complex data object, you usually use the combination of input () and eval () functions
The input data is essentially a tuple, so it is separated by commas. If multiple inputs are returned as a sequence as a whole,
Basic output: print () function:
The last sep is set to an empty character, indicating that there is no default space or other characters between the characters. End is also a null character indicating that the input does not wrap but the next statement is output.
Print function-formatting template
{0}, {1} can be regarded as the placeholder of the replacement object, and the content after the colon is the format specifier.
At this point, the study of "how to realize the assignment statement and basic input and output of python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.