In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Python data types and identifiers and judgment statements how to use, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Catalogue
There are six data types in Python, which are:
1. The difference between a list and a dictionary
two。 The difference between list and Yuanzu:
3. The difference between lists and collections:
4. The difference between a dictionary and a collection:
Common identifiers for Python
Keywords in Python
Sentence outline
If judgment statement
1. Judge in the case of assignment
two。 Judge in the case of obtaining the value
Logical operator
If-else
If nesting
Summary
There are six data types in Python, namely: string, number, Boolean type, list, meta-ancestor, dictionary, collection
It is divided into mutable types and immutable:
Mutable types: list, dictionary, collection immutable types? : number, string, Yuanzu 1. The difference between lists and dictionaries: similarities: 1. They are all variable types 2. They are all iterative differences: 1. The key of the dictionary is immutable object 2. The storage space of the dictionary is larger than that of listing 3. The query efficiency of the dictionary is higher than that of listing 2. The difference between list and Yuanzu: similarities: 1. They are all iterative differences: 1. The list is variable, the tuple is immutable 2. The list is dynamic, the length is not fixed, you can add, delete, change and check 3. The tuple is static, and the length has been determined not to be changed at the beginning. The difference between lists and collections: similarities: 1. All are mutable types that differ from each other: 1. The list is ordered and the elements are not unique, so you can slice 2. 5 according to the index. The set is unordered and the element is unique 3. Repeating elements are automatically filtered in the collection 4. The difference between dictionaries and collections: similarities: 1. Dictionaries and collections have no index, and cannot be sliced and manipulated according to the index. All are mutable types that differ from each other: 1. Dictionaries are the form of key-value pairs. The collection does not have a common identifier for the corresponding value value Python
What is an identifier:
Some of the symbols and name identifiers that developers customize in the program are defined by themselves, such as variable names, function names, etc.
Naming rules for identifiers:
1. Identifiers can only consist of letters, underscores "_", and numbers. two。 Identifiers cannot start with a number. 3. Identifiers cannot use keywords (cannot be the same as keywords in python). Keywords in Python
Python has some identifiers with special functions, which are called keywords.
Keyword, which is already used by python, so developers are not allowed to define identifiers with the same name as the keyword
Keyword
False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield
Sentence outline
If judgment statement if to judge the condition: when the condition is true, what to do 1. Judge age = 20if age > 18: print ("adult") else: print ("minor") in the case of assignment
two。 Judge age = input ("Please enter age:") if int (age) > = 18: print ("adult") else: print ("minor")
In the above case, it is just that the value of the age variable is different, resulting in different results; you can see the function of the if judgment statement: the code block statement will be executed only when certain conditions are met, otherwise the code block statement will not be executed.
Note: the code is indented to a tab key, or 4 spaces
Comparison (that is, relational) operator
Comparison operator in python
A=10b=20print (astatb) print ("=") print (astatb) print ("=") print (a > = b) print ("=") print (ab) print ("=") print (A150: if int (age)
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.