Professional Documents
Culture Documents
If Else Python
If Else Python
<operation>
elif<condition>:
<operation>
.....
else:
<operation>
a= int(input("enter a="))
if a%2 == 0:
print(a,"is even")
else:
print(a,"is odd")
a= int(input("enter a ="))
b= int(input("enter b="))
if a>b:
print(a,"is greater")
elif b>a:
print(b,"is greater")
else:
print("both are equal")
else:
print("error")
# nested if
if <condition>:
if <condition>:
<operation>
else:
<operation>
else:
<operation>
if (a%2 == 0):
if a>20:
else:
else:
print("error")