Computer Application Lab Assignment Date: 25.04.
25
ADAMAS UNIVERSITY
PYTHON PROGRAM (if statement)
Name - Shalini Tiwari
Department - Commerce
1. Write a program in python to check a person is eligible for loan or not.
(Hints: age>17 and monthly_income>5000)
Ans:
age=int(input("Enter the age:"))
monthly_income=int(input("Enter the monthy income"))
if(age>17 and monthly_income>5000):
print("The person is eligible for loan")
else:
print("The person is not eligible for loan")
2. write a program in pyrhon to print an appropriate greeting based on the time of day.
(Hints: 0 to 12:Good morning,12 to 17: Good Afternoon,17 to 21: Good Evening,
21 to 23: Good Night, otherwise: Invalid Input)
Ans:
time=int(input("Enter the time:"))
if(0>=time<=12):
print("Good morning")
elif(12>=time<=17):
print("Good afternoon")
elif(17>=time<=21):
print("Good evening")
elif(21>=time<=23):
print("Good night")
else:
print("Invalid Input")
3. Implement a python program to determine the type of triangle based on sides.
(Hints: determines the type of triangle (Equilateral, Isosceles, or Scalene) based on the
lengths of its sides.)
Ans:
side1=int(input("Enter the side1:"))
side2=int(input("Enter the side2:"))
side3=int(input("Enter the slide3:"))
if(side1+side2>side3 and side2+side3>side1 and side1+side3>side2):
if(side1==side2==side3):
print("The traingle is equilateral")
elif(side1==side2 or side2==side3 or side1==side3):
print("The traingle is isosceles")
else:
print("The traingle is scalene")
else:
print("The traingle is not valid")
4. Implement a python program to generate electricity bill.
(Hints: rental rs.100, units<100: Cost Rs. 5/unit, units 100 to 200:cost rs. 8/unit, units>200:
cost rs. 10/unit)
Ans:
units=int(input("Enter the units:"))
if units<0:
print("Invalid input")
elif units<100:
cost=units*5
elif units<=200:
cost=units*8
else:
cost=units*10
if units>=0:
cost:units+100
print("The electricity bill is",cost)