Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

PROGRAM 1

AVERAGE OF FIVE SUBJECTS GRADE

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

SALE PRICE OF GIVEN QUANTITY


AIM: To find and display the sale price for a given quantity.
SOURCE CODE:
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)

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:

RESULT: Successfully displayed the biggest and smallest in a list.


PROGRAM 5
DICTIONARY (MINIMUM & MAXIMUM)

AIM: To find the minimum and maximum in a dictionary.


SOURCE CODE:
dict={'x':345,'y':583,'z':803,'f':104,'g':92,'s':50,'j':60,'d':9}
max_value=max(dict)
min_value=min(dict)
print(max_value)
print(min_value)

OUTPUT:

RESULT: Successfully displayed the maximum and minimum in a dictionary.


PROGRAM 6
PROFIT AND LOSS

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

AIM: To find the number of vowels in a string


SOURCE CODE:
a=input("Enter the sentence:")
vowels=0
for i in a:
if i=="a" or i=="e" or i=="i" or i=="o" or i=="u":
vowels=vowels+1
print("The no.of vowels are:",vowels)
OUTPUT:

RESULT: Successfully displayed the number of vowels that are present in a string.
PROGRAM 8
STATES & CAPITALS IN A DICTIONARY

AIM: To enter different states and capitals in a dictionary.


SOURCE CODE:
dict={}
n=int(input("Enter the limit:"))
for i in range(n):
state=input("Enter the state:")
capital=input("Enter the Capital:")
dict[state]=capital
print(dict)
OUTPUT:

RESULT: Successfully displayed states and capitals in a dictionary.


PROGRAM 9

EMI (EQUAL MONTHLY INSTALLMENT)

AIM:- To calculate EMI.


SOURCE CODE:
amount=int(input("Enter the amount"))
period=int(input("Enter the period(in months"))
interstate=int(input("Enter the interest rate"))
interest=amount*period*interstate/100
total=amount+interest
EMI=total/(period*12)
print("EMI amount",EMI)

OUTPUT:

RESULT: Successfully displayed the calculated EMI.


PROGRAM 10
CALCULATIONS OF TAX

AIM: To calculate tax (example from GST/Income Tax).


10,000-40,000 2.00%
40,000-1,00,000 5.00%
1,00,000-1,50,000 7.00%

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 calculated tax.


PROGRAM 11
SUM OF SQUARES OF FIRST 20 NATURAL NUMBERS

AIM: To find the sum of squares of first 20 natural numbers.


SOURCE CODE:
sum=0
for i in
range(1,11):
sum+=i**2
print("Sum of squares of the first 20 natural numbers:",sum)
OUTPUT:

RESULT: Successfully displayed the sum of squares of the first 20 natural numbers.
PROGRAM 12
MULTIPLES OF GIVEN NUMBERS

AIM: - To find multiples of given numbers using loop function.


SOURCE CODE:
n=int(input('Enter the limit:'))
for i in range(1,n+1):
multiple=n*i
print(multiple)
OUTPUT:

RESULT: Successfully displayed the multiples of given 5 numbers.


PROGRAM 13
WORDS STARTING WITH SAME ALPHABET

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

AIM: To print the number of occurrences of a given alphabet in a given string.

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

AIM: To check whether the given year is a 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.

You might also like