If....Elif....Else Statement || Conditional Statements in python || Part - 3 #python3 #python

preview_player
Показать описание
In this video, I have discussed the basic If...elif...else condition in python and its implementation.

Why do we need If....elif....else conditional statements?
'IF' statement will be executed if a certain condition is correct but the else statement will be executed only when IF block is not executed that is when a given condition is wrong. So we cannot have more than one condition in If and else statement so elif was introduced which actually means else if, in which we can write some other condition, that means if our "IF" condition is wrong then the code will execute the "elif" block and there it will check for the other condition and if it also fails then finally else block will be executed.
Because of elif statement we can have infinite conditions in our if..elif..else code.

For example, when do we remove the charger from our mobile?
It is simple when it's 100% charged
similarly in code this logic as:

battery_percentage = 99
if battery_percentage == 100:
print("Charged, please remove the charger")
elif batery_percentage == 50:
print("Halfway and still charging")
else:
print("Still Charging")
Рекомендации по теме
Комментарии
Автор

Sir, it's worth to watch your videos by skipping University lectures. 👍

VarunSingh-omks
welcome to shbcf.ru