Here is a very useful little tutorial basically remember, but it takes a long time to review
if sentence (judgment statement)---------------------------------------- ---------------
i = 1
if i > 0:
print ' positive i '
i = i + 1
elif i = = 0:
print ' I is 0 '
i = i * ten
else:
print ' negative i '
i = i-1
print ' New I: ', I
--------------------------------------------------for statement (Loop)-----------------------------------------------------------
For I in range: # for element in sequence:
Print I**2 # Action statement
result:1,4,9,16,25,36,49,64,81
-------------------------------------------------while Statement (Loop)--------------------------------------------------------------
While condition:
Statement
As an example:
>>> i = 5 # give variable i assign value
>>> While I < 10:
Print I
i = i +1
Result
5
6
7
8
9
---------------------------------------------------------interrupt-continue--------- ------------------------------------------------------
> >> for I in range:
if I = = 2:
Continue #同一循环的某一环, continue, skip this loop and proceed to the next loop
print I
result:
0
1
3
4
5
6
7
8
9
---------------------------------------------------------Interrupt-break-------------------------------------------------------- -------
>>> for I in range (10):
if i = = 2:
Break #停止整个循环, do not proceed to the next loop
Print I
Result
0
1
Getting Started Tutorial 2