python Road Day

python Control Scheme:

1.if: use if its retracted to determine whether to execute the code, if the judgment is True, the following indented code block is executed. Is determined to False, the following block does not execute indented

         Also it involves nested if, it also can be used to write elif. For example with the following code:

int = Score (the INPUT ( ' Please enter your score: ' ))
 IF Score <= 90 :
     Print ( ' ! very good ' )
 elif Score <= 80 : 
     Print ( ' Excellent! ' )
if statements use

2.while cycle: when the determination while the condition is True, an endless loop will be retracted while in the code block.

                       Until while when it is judged under the conditions Flase, will abort the cycle indented code block.

a = 0
while a < 3 :
Print(a)
a += 1
while loop
a = 1 
while a <  2 :
print(a)
while infinite loop

3.for cycle: also known as iterative loops, for loops when used in a list or dictionary, it will take to list or dictionary of all the elements, is a dictionary if so,
                   only to take key.
                   If it is a within the scope of the cycle, then it only takes less than last element,
                   it is more figurative representation of a speech, called care regardless of the end.

for i in range(1,10):
    print(i)
for loop

4.else: It can be used with if, or while, or for the use of loops.

                     else if ......: belonging to a layer at the same time if and else, when the condition is not satisfied if, else indented under the code is executed, else if and only a satisfied.


                    while ..... else: When the while loop is not break, it will execute else.

 

                    for ...... else: When the for loop there is no break, performs else

5. The BREAK statement: refers to the exit layer of the present cycle, it can be said that the Terminator, the while statement is through the bad it off cycle. But it can only suspend it from the nearest body of the while.

6. The Continue statement: refers to layer out the present cycle, then execution cycle from the beginning.

This is my fourth day study concluded from experience.

Guess you like

Origin www.cnblogs.com/wujc3/p/11123308.html