2.1 Boolean values (first character uppercase)
- True
- False
2.2 Comparison operators
Operators | meaning |
== | Equal, for comparison |
!= | not equal to |
> | more than the |
< | Less than |
<= | Less than or equal |
>= | greater or equal to |
Boolean operators 2.3
- and
- or
- not
2.4 Mixed Boolean and comparison operators
>>> (4>8) and (5>0)
False
2.5 flow control element
- Controlled conditions
- Block
- Increased only start block
- Code block may contain other code blocks
- Indent zero, or reduce surrounding the outer code block is retracted, the code block
2.7 control flow statements
2.7.1 if statement
if controlled conditions:
if clause
2.7.2 else statements
else :
else clause
2.7.3 elif statement
elif controlled conditions:
elif clause
If there is a series of elif clauses, only one bar or a zero is performed. Once a statement is executed, the rest of the elif clause will be automatically skipped.
2.7.4 while loop
while controlled conditions:
while clause
2.7.6 break statement: exit the while loop
2.7.7 continue statement: skip the current cycle, the next cycle into the
2.7.8 for circulation and range () statement
for variable names in range ():
for clause
# Range () usage:
range(5): 0 1 2 3 4
range(1,5): 1 2 3 4
range (1,5,2) [range (play, stop, step)]: 1,3
2.8 Import module
import module name [, a module name, module name 2]
from import statement: eg from random import *, without the use of random prefix function is called random module [taking into account use the full name of the module to make the code more readable, this is not recommended import form].