Process Control
Boolean value
temp = True Temp = False
Compare symbols
= = = < <= > >=
and or non-
And Or not
Comparison of mixed Booleans
(4<5) and (5<6)
Process Control elements
Conditional statement if Else
code block
Program execution
Process description
If Else
If Name= John:
Print ("My name is John");
Esle:
Print ("My name is not John");
Elif (ElseIf in other languages)
While loop
temp = 0
While temp <5
Print (' Hello world ')
temp = temp + 1;
Break statement: Jump out of
Continue statement: Jump out of this time to continue the next cycle
For loop and range functions:
For NUM in range (10)
Total = total + num;
Print total;
Range and interval of range
For NUM in range (0,10,2)
print (num);//0,2,4,6,8
For NUM in range (10,-2,-2)
print (num);//10,8,6,4,2,0
Importing packages
Import Random
For Num in range (3)
Print (Random.readint (1,10))/prints three times less than 10 random numbers
Import multiple packages at the same time:
Import Random,sys,amth,os
End Program
Sys.exit ();
Python Automated Scripting Learning (ii)