Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Python if-else and Control Flow | Python tutorials Bestitworriors
Python if-else and Control Flow
Python if-else and Control Flow | Python tutorials Bestitworriors - Python if-else use to execute pice of code if some condation match to criteria . If-else use to check condation if condation match the execute If(Condation == true)then execute If block code // then after that we can check further condatio using else if(Condation ==true)if match then execute //Code part if none of condation match then execute the else part code //Code.
Some Key Points of Python IF-Else
- Python use to execute pice of code on condation match
- Use if Condation to check condation if(cond == true){//code}
- Use else if condation to check further condation else if (cond == true) {//Code}
- If none of condation match the execute the else part else{//Code}
- Elif condation also work same as else if
Code
var1 = 33
var2 = 33
if var1 > var2:
print("var is greater than var2")
elif var1 == var2:
print("a and b are equal")
var3 = 10
var4 = 5
if var3 > var4:
print("var3 is greater than var4")
elif var3 == var4:
print("var3 and var4 are equal")
else:
print("var3 is less than var4")
OutPut
a and b are equal
var3 is greater than var4
var3 is greater than var4
0 Comments