10 If Programs Of Python
10 If Programs Of Python
1stprogram
Input:
marks=int(input("enter your final test marks"))
if marks>=99:
print("You will get a new phone.")
elif marks>=95 and marks<=98:
print("Study hard and get good marks next time or I will kick you out
of the house")
else:
print("You are grounded for a month and no iPad")
Output
1stcase-
enter your final test marks100
You will get a new phone.
2ndcase-
enter your final test marks97
Study hard and get good marks next time or I will kick you out
of the house.
3rdcase-
enter your final test marks94
You are grounded for a month and no iPad.
2ndprogram
Input:
v=int(input("Select your method of transportation number
present in the box{(3)car,(2)bus,(1)cycle):"))
if v>2:
print("You will reach to the location quickly but you increase
the pollution the in air.")
elif v>1 and v<3:
print("Great job you are protecting your environment.")
else:
print("You are going to be in good health but remember to
take your raincoat during rainy season.")
Output:
1stcase-
Select your method of transportation number present in the
box{(3)car,(2)bus,(1)cycle):1
You are going to be in good health but remember to take your
raincoat during rainy season.
2ndcase-
Select your method of transportation number present in the
box{(3)car,(2)bus,(1)cycle):2
Great job you are protecting your environment.
3rdcase-
Select your method of transportation number present in the
box{(3)car,(2)bus,(1)cycle):3
You will reach to the location quickly but you increase the
pollution the in air.
3rdprogram
Input:
Output:
1stcase-
2ndcase-
Input:
n=int(input("enter a no :"))
r=n%2
if r==0:
print("even")
else:
print ("odd")
Output:
1stcase-
enter a no :3
odd
2ndcase-
enter a no :98345678
even
5thprogram
Input:
Output:
1stcase-
2ndcase-
3rdcase-
enter number =0
Number is zero
6thprogram
Input:
yr=int(input("enter year"))
if yr%100==0:
if yr%400==0:
print("leap year")
else:
print("not a leap year")
else:
if yr%4==0:
print("leap year")
else:
print("not a leap year")
Output:
1stcase-
2ndcase-
Input:
l=int(input("length= "))
b=int(input("breadth= "))
if l==b:
print("it is a square")
else:
print("it is a rectangle")
Output:
1stcase-
length= 4
breadth= 4
it is a square
2ndcase-
length= 6
breadth= 9
it is a rectangle
8thprogram
Input:
Output:
1stcase-
2ndcase-
Input:
Output:
1stcase-
2ndcase-
Output:
1stcase-
enter temp.= 90
water
2ndcase-
3rdcase-