1. If ... else
1 a=62if a>=5:3 print("TheA is bigger than 5")4Else:5 print( " The A is smaller than 5 ")
2. For loop
1 # for I in range: #默认从0开始, stepping is 1 equivalent to C language for (i=0;i<10;i++) 2 for in Range (1,10,3):# starting from 1, the step is 33 print("Loop: ", i)
3. While loop
1 count=02 while True:3 print(" You are the wind I am the sand, wrapped around the horizon ... " , Count) 4 Count +=1
4. Break and Continue
1 #Break to completely exit this layer loop2 whileTrue:3 Print("break:123")4 Break5 Print("456")6 7 #continue is used to exit this loop and continue the next cycle8 whileTrue:9 Print("continue:123")Ten Continue One Print("456")
5, While+else
# Unlike other languages else, which is usually only the same as if, there is a while ... else statement in Python, and the else function after the while is the
When the while loop executes normally and the middle is not interrupted by a break, the statement after the else is executed
Python Basics (3) If_else, for, while, break, and continue