Python programs
"""[01] PROGRAM TO FIND THE AVERAGE AND GRADE OF GIVEN
MARKS"""
subject_1 = int(input("Enter marks of chemistry :"))
subject_2 = int(input("Enter marks of physics :"))
subject_3 = int(input("Enter marks of maths:"))
subject_4 = int(input("Enter marks of english:"))
subject_5 = int(input("Enter marks of ip:"))
avg = (subject_1+subject_2+subject_3+subject_4+subject_5)/5
if(avg>=90):
print("Grade: A")
elif(avg>=80&avg<90):
print("Grade: B")
elif(avg>=70&avg<80):
print("Grade: C")
elif(avg>=60&avg<70):
print("Grade: D")
else:
print("Grade: F")
=======================================================================================
"""[02] PROGRAM TO FIND SALE PRICE OF AN ITEM WITH GIVEN
PRICE AND DISCOUNT"""
price = float(input("Enter Price : "))
dp = float(input("Enter discount % : "))
discount=price*dp/100
sp = price-discount
print("Cost Price : ",price)
print("Discount: ",discount)
print("Selling Price : ",sp)
_______________________________________________________________________________________
=======================================================================================
"""[03] PROGAM TO CALCULATE PERIMETER/CIRCUMFERENCE AND
AREA OF SHAPES SUCH AS TRINAGLE, RECTANGLE, SQUARE AND
CIRCLE"""
print("chose no. between 1 to 4")
print("1 = triangle")
print("2 = rectangle")
print("3 = circle")
print("4 = squar")
no = int(input("enter your choice:"))
if(no == 1):
side_1 = float(input("length of first side:"))
side_2 = float(input("length of second sid:"))
side_3 = float(input("length of third sid:"))
height = float(input("height of triangl:"))
peri_tri = (side_1+side_2+side_3)
area_tri = (1/2*side_1*height)
print("perimeter of triangle is =",peri_tri)
print("area of triangle is =",area_tri)
elif(no == 2):
length = float(input("length of rectangle:"))
width = float(input("width of rctangle:"))
peri_rect = 2*(length + width)
area_rect = length*width
print("the perimter of rectangle =",peri_rect)
print("the area of rctangle =",area_rect)
elif(no == 3):
radius = float(input("radius of circle:"))
area_cir = 3.14*(radius**2)
peri_cir = 2*3.14*radius
print("perimeter of circle is",peri_cir)
print("area of circle is =",area_cir)
elif(no == 4):
side = float(input("first side of square:"))
peri_sq = 4*side
area_sq = side*side
print("perimeter of square =",peri_sq)
print("area os square =",area_sq)
else:
print("invalid shape is chosen")
_______________________________________________________________________________________
=======================================================================================
""" [04] PROGRAM TO CALCULATE SIMPLE AND COMPOUND
INTEREST """
principal = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
S_I = (principal*time*rate)/100
C_I = principal*((1+rate/100)**time-1)
print("Simple interest is=",(S_I))
print("Compound interest is=",(C_I))
_______________________________________________________________________________________
=======================================================================================
"""[5] PROGRAM TO FIND THE SUM OF SQUARES OF THE 100
NATURAL NUMBERS"""
sum = 0
for num in range(1,101):
sum = sum +num
print("the sum of 100 natural numbers =",sum)
__________________________________________________________
===========================================================================
"""[6] PROGRAM TO FIND THE LARGEST/SMALLEST NUMBERS IN A
LIST"""
val = eval(input("enter list"))
print(val)
largest_no = max(val)
smallest_no = min(val)
print("the largest no in the given list =",largest_no)
print("the smallest no in the given list =",smallest_no)
__________________________________________________________
===========================================================================