一 Print and None
-
None Indicates that Nothing is Returned
The special value None represents nothing in Python A function that does not explicitly return a value will return None Careful: None is not displayed by the interpreter as the value of an expression
-
Pure Functions & Non-Pure Functions
Pure Functions: just return values Non-Pure Functions: have side effects
二 Multiple Environments
-
Life Cycle of a User-Defined Function
Def statement: A new function is created! Name bound to that function in the current frame Call expression: Operator & operands evaluated Function (value of operator)called on arguments (values of operands) Calling/Applying: A new frame is created! Parameters bound to arguments Body is executed in that new environment
-
Names Have No Meaning Without Environments
Every expression is evaluated in the context of an environment. A name evaluates to the value bound to that name in the earliest frame of the current environment in which that name is found.
-
write test in doctest
"""<description> >>> q,r = divide_exact(2013,10) >>> q 201 >>> r 3 """
in cmd input
python -m doctest -v **.py
-
Conditional Statements 4.1 Statements
A statement is executed by the interpreter to perform an action
4.2 Compound Statements
4.3 Conditional Statements
False values in Python: False, 0, '', None
True values in Python: Anything else (True)
5. Iteration 5.1 While Statements
Execution Rule for While Statements:
1. Evaluate the header’s expression.
2. If it is a true value, execute the (whole) suite, then return to step 1.