Professional Documents
Culture Documents
Ip Record Mariyam
Ip Record Mariyam
AIM: To find and display the average and grade for given marks for 5 different subjects’ (each subject out
of 100).
SOURCE CODE:
a=float(input("Enter the marks for English :"))
b=float(input("Enter the marks for Math:"))
c=float(input("Enter the marks for Science:"))
d=float(input("Enter the marks for IT:"))
e=float(input("Enter the marks for Social
Science:")) avg=(a+b+c+d+e)/5
print(avg)
if avg>=90:
print("A Grade")
elif avg>80 and avg<90:
print("B Grade")
elif avg>70 and avg<80:
print("C Grade")
elif avg>60 and avg<70:
print("D Grade")
elif avg>50 and avg<60:
print(“E Grade”)
else:
print("F Grade")
OUTPUT:
RESULT: Successfully displayed the average and grade for given marks of 5 different subjects.
PROGRAM 2
OUTPUT:
RESULT:
Successfully displayed the sale price for given quantity.
PROGRAM 3
AREA/PERIMETER/CIRCUMFERENCE
AIM:- To find and display the area/perimeter/circumference of different shapes.
SOURCE CODE:
shape=str(input("Enter the name of shape:"))
if shape=="rectangle":
l=int(input("Enter rectangle's length:"))
b=int(input("Enter rectangle's breadth:"))
print(l*b)
elif shape=="square":
s=int(input("Enter square's side length: "))
print(s*s)
elif shape=="triangle":
h = int(input("Enter triangle's height: "))
b = int(input("Enter triangle's breadth: "))
print(0.5*b*h)
else:
print("Shape is not
available")
OUTPUT:
RESULT: Successfully displayed the area for 3 different shapes.
PROGRAM 4
LIST (BIGGEST & SMALLEST)
AIM: To find the list numbers which is smallest and biggest.
SOURCE CODE:
list=[15,21,33,21,76,50,17]
maxvalue=max(list)
minvalue=min(list)
print(maxvalue)
print(minvalue)
OUTPUT:
OUTPUT:
AIM: To find the profit and loss using if-elif-else conditional statements.
SOURCE CODE:
costprice=float(input("Enter the cost price of item:"))
sellingprice=float(input("Enter the selling price of item:"))
if(sellingprice>costprice):
profit=sellingprice-costprice
print("Profit:",profit)
elif(costprice>sellingprice):
loss=costprice-sellingprice
print("Loss:",loss)
else:
print("No Profit or Loss")
OUTPUT:
RESULT: Successfully displayed the profit and loss using the if-elif-else conditional
statements.
PROGRAM 7
NUMBER OF VOWELS IN A STRING
RESULT: Successfully displayed the number of vowels that are present in a string.
PROGRAM 8
STATES & CAPITALS IN A DICTIONARY
OUTPUT:
SOURCE CODE:
Amount=int(input("Enter the amount:"))
if Amount>=10000 and Amount<=40000:
print("Tax amount to be paid:" ,Amount*(2/100))
elif Amount>=40000 and Amount<=100000:
print("Tax amount to be paid:" ,Amount*(5/100))
elif Amount>=100000 and Amount<=150000:
print("Tax amount to be paid:" ,Amount*(7/100))
else:
print("No amount")
OUTPUT:
RESULT: Successfully displayed the sum of squares of the first 20 natural numbers.
PROGRAM 12
MULTIPLES OF GIVEN NUMBERS
AIM: To print the words starting with a particular alphabet in a user entered string.
SOURCE CODE:
a=input("Enter the sentence")
b=input("Enter the alphabet")
for i in a.split():
if i[0]==b:
print(i)
OUTPUT:
RESULT: Successfully found and displayed the words starting with a particular alphabet in a
user entered string.
PROGRAM 14
NUMBER OF OCCURRENCES OF A GIVEN ALPHABET
SOURCE CODE:
a=input("Enter the sentence:")
b=input("Enter the alphabet")
print("the number of occurrences of a given alphabet in a given string:",a.count(b))
OUTPUT:
RESULT: Successfully found and displayed the number of occurrences of a given alphabet
in a given string.
PROGRAM 15
LEAP YEAR OR NOT
SOURCE CODE:
a=int(input("Enter the year:"))
if (a%400==0) and (a%100==0):
print("It is a leap year")
elif (a%4==0) and (a%100!=0):
print("It is a leap year")
else:
print("It is not a leap year")
OUTPUT:
RESULT: Successfully checked whether the given year is a leap year or not.