Python -----> process control, python ----- Process
1:
If 1 <2: ("the condition is True, and the result is True ")
Print ('true ')
Else:
Print ('forse ')
2:
I = 0 (assign 0 to I)
While I <5: ("True if I is less than 5 ")
Print (I)
I + = 1; ("I add 1 each time. If I do not write, it will jump into an endless loop ")
3: for I in range (1, 10 ):
For j in range (1, I + j ):
Print ('{}* {}={}\ t'. format (j, I, j * I), end = '')
Print () ("line feed ")
If condition judgment statement:
1: if is followed by a condition (Note: This is different from java, and the condition does not need to be added ())
If the condition is True, a (True) is returned and the following statement is executed.
If the condition is not true, execute the statements in else. (Note: Code indentation)
Loop statement:
2: while
The judgment condition can be any expression, and any non-zero or non-null value is True. The judgment condition Forse
3:
Output a 9-9 multiplication table using a for Loop
1--3 (top instance)
4: variable exchange
A = 8
B = 1
A, B = B, a ("output result: B = 8, a = 1 ")
5: Random Number
Import random ("import random ")
Print (random. randint () ("random number range 0-9 ")