5_Decision Making
5_Decision Making
Learning objective
• Conditional Statements
• If statement
• If….else statement
• Nested if statement
• If …..elif statement
Conditional Statements
• There are situations in real life when we need to do some specific
task and based on some specific conditions, we decide what we
should do next.
a = 15
if (a > 10): #you can also write as if a>10:
print("a is greater")
If…else statement
• An if statement can be followed by an optional else statement,
which executes when the Boolean expression is false.
x = 305
y = 405
if x > y:
print("x is greater")
else:
print("y is greater")
Nested if statement
• A nested if is an if statement that is the target of another if
statement.