- Get link
- X
- Other Apps
If...Else Statement in Python
Hello Programmer!
In this tutorial, I will teach you the if-else statement in Python. This is a very important statement in python. If you have any questions then you can comment below or mail me at - arefinanwar112@gmail.com. So let's get started.
We all know what is "if" and "else". Like "if something happens then this will happen or else if it doesn't happen then nothing will happen.
Example:
if dog is sleeping
give him food
else
not give him food
I hope that you have understood what is if-else. So, what is the python if-else statement? The python if-else statement is used to control the flow of a program. In python, we have to use syntax in order to add an if-else statement. Example:
if(condition):
do something
else:
do something else
Explanation of the above code, if the condition is true then it will do the work which is in the if block else if the condition is false then it will do the work which is in the else block.
Example:
a = 10
if(a == 10):
print("a = 10")
else:
print ("a does not equal to 10")
Now, you must be wondering that if I want to add a statement between if & else then what will you do?
If you want to know how you can do that then you have to read this---https://pythonproramming.blogspot.com/2020/12/elif-statement-in-python.html
Congratulations! Now you know what is an if-else statement in python. This was a very important concept of python. If you have any questions then you can comment below or mail me at - arefinanwar112@gmail.com.
Join Facebook group -https://www.facebook.com/Python-Programming-106878491339183
python,if else statement in python,if else in python,if statement in python,conditional statements in python,python if else statement,python tutorial,learn python,python programming,python if else,python 3,if statements python,python tutorial for beginners,conditional statements python,statement,python for beginners,if statement,if else statements,python if statement,if else python,python if else statement example,python if statements,python conditional statements
Comments
Post a Comment