If condition statement
(1) If condition judgment: (colon)
If 1==1:
Print (' Really nothing ')
Else
Print (' It will be later ')
Description of the # # # code block: In the same column as the code block, as above, if the print is a block of code.
# # #一般为空4格为标识, or press the TAB key directly.
(2) If the nesting:
If n==1:
Print (' haha ')
If n==2:
Print (' hehe ')
Else
Print (' hehe ')
Else
Print (' haha ')
# #注意代码块 ...
(3) Use of If elif:
If n==1:
Print (' Hello ')
Elif n==2:
Print (' Years later ')
Elif n==3:
Print (' True fragrance ')
Else
Print (' SB ')
If you want direct else, you need to:
If n==1:
Pass keyword: Do not perform the current direct skip.
else:
Print (' SB ')
How to use the while:
(1) While Count ==1:
Print ("haha")
You also need to be aware of code blocks when you use them.
(2) Use of while else
While Count <10:
Print ("haha")
Count =count +1
Else
Print ("hehe")
Pay attention to the code block when using
(3) Continue break
While count<10:
If count==7:
Count=count+1
Print (' haha ')
Continue
Else
Print (' haha ')
Count=count+1
The use of continue is that when the if is met, if is encountered continue, the if is returned and the execution continues. That is, when =7, continue to the else output haha
Break, the effect of break is to jump out of all loops.
To the previous supplement:
(1) When a real string can only be "" "" "" "" "in several ways
Python's basic statement