Decision Making

In Python programming, conditional statements perform different computations or actions depending on whether a specific condition holds true or false. Based on it, certain decisions are to be made.

Basically, conditional statements are taken care by Python if  statements. This is sometimes associated with elif  or else  statements.

For them to work properly, Python relies on indentation, using white space, to define scope in the code instead of using curly-brackets. The following example shows this: 

# Conditional Test 1
a = 100
b = 66
if a > b:
print("a is greater than b")
elif a == b:
print("a and b are equal")
else:
print("a is lesser than b")

Output:

a is greater than b

Following example demonstrates nested if statement to find the greatest among three given integers:

# Conditional Test 2
a = 80
b = 66
c = 95
if a > b:
if a > c:
print("a is the greatest")
else:
print("c is the greatest")
else:
if b > c:
print("b is the greatest")
else:
print("c is the greatest")

Output:

c is the greatest