#!/bin/python
# check if var is set/true
var=Trueifnotvar:print"I'm false"elifvar:print"I'm true"# Check if integer smaller than x
x=1ifx<=1:print"smaller or equal 1"elifx<=10:print"smaller or equal 10"else:print"bigger than 10"# Check if variable test is set
#test = "Hello World"
try:testexceptNameError:test=NoneiftestisNone:print"Variable test is not set"else:printtest
While loop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/python
# easy loop do while var is False
var=Falsewhile(var==False):print"var is false"var=True# More complex loop print message "var is False" 10 times before break out of while"
var=Falsei=0while(var==False):while(i<=10):i=i+1print"var is False"#var = True
break