Practical
Practical
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
English =float(input("Enter English Marks:"))
CS =float(input("Enter Computer Science Marks:"))
Physics =float(input("Enter Physics Marks:"))
Chemistry =float(input("Enter Chemistry Marks:"))
Mathematics =float(input("Enter Mathematics Marks:"))
average =float((English+CS+Physics+Chemistry+Mathematics)/5)
print("Average of Marks is",average)
if average>90:
print("You scored GRADE A")
elif average<=90 and average >80:
print("You scored GRADE B")
elif average<=70 and average <80:
print("You scored GRADE C")
elif average<=60 and average <70:
print("You scored GRADE D")
elif average<=50 and average <60:
print("You scored GRADE E")
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
cost_price=float(input("Enter the price of item:"))
discount=float(input("Enter the discount %:"))
selling_price=float(((100-discount)/cost_price)*100)
print("The selling price of item is:",selling_price)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
import math
radius = float(input("Enter the radius of the Circle :- "))
area = math.pi * radius * radius
circumference = 2 * math.pi * radius
print("Area of a Circle is :- ",area)
print("Circumference of a Circle is : – ",circumference)
# Square
side = float(input("Enter side of the Square :-"))
area = side * side
perimeter = 4 * side
print("Area of Square is ",area)
print("Perimeter of Square is ",perimeter)
# rectangle
length = float(input("Enter the length of a rectangle :-"))
breadth = float(input("Enter the Breadth of a rectangle :-"))
area = length * breadth
perimeter = 2 *(length + breadth)
print("Area of Rectangle is ",area)
print("Perimeter of Rectangle is ",perimeter)
# Triangle
side1 = float(input("Enter Side 1 of the traingle :-"))
side2 = float(input("Enter Side 2 of the traingle :-"))
side3 = float(input("Enter Side 3 of the traingle :-"))
s =(side1 +side2 + side3)/2
area = math.sqrt(s*(s-side1)*(s-side2)*(s-side3))
per = side1 + side2 + side3
print("Area of Triangle is ",area)
print("Perimeter of Triangle is ",per)
Result : Code executed successfully.
Program: 6
Aim: To calculate Simple and Compound interest.
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
principal = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
simple_interest = (principal*time*rate)/100
compound_interest = principal *( (1+rate/100)**time - 1)
print("Simple interest is:", simple_interest)
print("Compound interest is:", compound_interest)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
sp = float(input("Enter the Selling Price :- "))
cp = float(input("Enter the Cost Price :- "))
if sp > cp :
profit = sp - cp
profit_per = (profit * 100)//cp
print("The Profit is :- ",profit)
print("The Profit percentage is :- ", profit_per)
elif sp <cp:
loss = cp - sp
loss_per = (loss * 100)//cp
print("The Loss is :- ",loss)
print("The Loss percentage is :-",loss_per)
else:
print("No Profit No Loss")
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
amount = float(input("Enter the base amount :- "))
period = float(input("Enter the time period :- "))
rate = float(input("Enter rate of Interest :- "))
interest = amount * period * rate /100
total = amount + interest
emi = total /(period * 12)
print("EMI amount is ",emi)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
op=float(input("Enter original Price:-"))
np = float(input("Enter Net Price:-"))
GST_amt = np - op
GST_per = ((GST_amt * 100) / op)
print("GST Rate = %.2f"%GST_per,"%")
print("GST Amount = ",GST_amt)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
lst = []
num = int(input('How many numbers: '))
for n in range(num):
numbers = int(input('Enter number : '))
lst.append(numbers)
print("Maximum element in the list is :", max(lst),
"\nMinimum element in the list is :", min(lst))
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
NumList = []
Number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, Number + 1):
value = int(input("Please enter the Value of %d Element : " %i))
NumList.append(value)
print("The Smallest Element in this List is : ", min(NumList))
print("The Largest Element in this List is : ", max(NumList))
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
sum1 = 0
for i in range(1, 101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ", sum1)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
#input
n = int(input("Enter the number to display multiples:"))
m = int(input("Enter the number to display n multiples:"))
#computing multiples
multiple = range(n, (n * m) + 1, n)
print(list(multiple))
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
txt = input("Enter string:")
vowels = 0
for i in txt:
if(i=='a' or i=='e' or i=='i' or i=='o' or \
i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
vowels = vowels + 1
print("Number of vowels are:", vowels)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
txt=input("Enter the text:")
al=input("Enter alphabet to print the words:")
for i in txt.split():
if i.startswith(al):
print(i)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
string = input("Please enter your own String : ")
char = input("Please enter your own Character : ")
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
print("The total Number of Times ",char, "has Occurred = " , count)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
dict1 = { }
ans = 'y'
while(ans=='y'):
st_name = input("Enter name of the State:")
capital = input("Enter its capital:")
dict1[st_name]=capital
ans = input("Do you want to insert more records y/n")
print(dict1)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
students = dict()
n = int(input("How many students are there :"))
for i in range(n):
sname = input("enter name of the student :")
marks = []
for j in range(5):
mark = float(input("Enter marks: "))
marks.append(mark)
students[sname]= marks
print("Created dictionary of students is ",students)
Procedure:
i. Go to start Menu
ii. Go to programs Python 3.11.0 IDLE
iii. File New File
Source Code:
my_dict = {'x': 500, 'y': 5874, 'z': 560}
val = my_dict.values( )
print('max value' , max(val))
print('min value' , min(val))