Class 05 Conditinal Statements (If - Elif - Else)
Class 05 Conditinal Statements (If - Elif - Else)
PYTHON 5
Control Structures
Control Structures
Yeasir Arafat Ratul
CONTROL
What is conditional statement?
Yeasir Arafat Ratul
যদি – if
তা না হলে - else
When a condition is executed?
Yeasir Arafat Ratul
elif False:
Then Executed
elif True:
Then Not Executed
if (condition): a>b
if False:
statements Then Not Executed
Or
elif(condition): elif False:
statements a == b
Then Executed
elif(condition): Or
elif True:
statements Then Not Executed
a > b and b > c
else: else (All False)
statements Or
Then Executed
a > b or b > c
How to use a condition
Yeasir Arafat Ratul
• if
• if - else
• if – elif – else
• Nested – if - else
Compound Condition
Yeasir Arafat Ratul
if (condition):
statements
if(condition):
statements
elif(condition):
statements
else:
statements
else:
statements
MATCH - CASE
case ‘patternN’:
//statement n
case other:
// statement
MATCH – CASE EXAMPLE
match data:
case 1:
print("You Are First")
case 2:
print("You Are Second")
case 3:
print("You Are Third")
# default case
case other:
print("Not in Top Three")
MATCH – CASE Wildcard
case _:
// statement
Yeasir Arafat Ratul
THANK YOU