6.1. Checking if true or false#
true is written as True
false is written as False
a=True
if a==True:
print('do this')
do this
6.1.1. Checking if true:#
# or use this directly:
if a:
print('do this')
do this
6.1.2. Checking if false:#
False in python=empty values=(),[],{},0,0.0,””,None
Note: space is not false,empty is false
if not a:
print('do this')
6.1.3. Note#
Comparison operators(<,>,==,!=) returns bools
1<2
0<=1
1==2
1!=0