Python programs use if commands and conditions to make decisions.
Indentation (4 spaces) is used to show what actions have to be taken.
if
Do something or nothing:
# if temperature < 17: print('It is too cold') #
if-else
Do one thing or another:
# if speed > 60: print('That is over the national speed limit') else: print('That is inside the national speed limit') #
if-elif-else:
Do one of several things:
# if mark >= 70: grade = 'A' elif mark >=60: grade = 'B' elif mark >=50: grade = 'C' elif mark >=40: grade = "D" else: grade = "F" #