Fifth chapter: Conditions, loops, and other statements
1. bool (): the BOOL function can return the Boolean type of the argument to true or false.
2. The equality operator is two equals = =.
3. Is is the identity operator.
4. Boolean operator : and,or,not
5. A If B else: If B is true, return a, otherwise, return B.
6. Keyword assert, if the condition must be true , the program will work properly, otherwise an exception occurs.
7. The range function can create a sequence, the first parameter is the lower bound (inclusive), and the second argument is the upper bound (not included).
8. The Xrange function is the same as the range function, but only one number is created at a time.
9. The zip function can turn multiple sequences into a tuple return (which can handle unequal sequences).
10. The keyword break can terminate the entire loop.
11. Keyword continue terminates the current loop, and then begins the next round of loops.
12. List derivation: [X*x for x in range] if x 3 ==0], create a new list by using a different list .
Pass: Do nothing and are useful for unfinished functions and classes.
Del:del keyword Delete is two things, one is the object's reference , and the other is the name of the variable, Del is not deleted value , in Python is There is no way to delete the value, and the Python interpreter is responsible for the memory collection.
The. EXEC: the keyword exec executes the python code stored in the string and can provide the namespace for the EXEC statement. If you print the dictionary scope, all of the built- in functions and values are included.
>>>from Import = {}>>>exec'sqrt=1' in scope >>>sqrt (4)
2.0>>>sqrt['sqrt']
1
The eval () function : You can evaluate an expression (written as a string), or you can provide a namespace as the keyword exec does.
Basic Python Tutorial Chapter 5th conditions, loops and other statements reading notes