List of Program For Practical File With Source Code
List of Program For Practical File With Source Code
Source Code:-
mm=int(input("Enter the maximum marks:"))
eng=int(input("Enter the marks of English:"))
acc=int(input("Enter the marks of Accountancy:"))
bs=int(input("Enter the marks of Business Studies:"))
eco=int(input("Enter the marks of Economics:"))
ip=int(input("Enter the marks of Informatics Practices:"))
tot=eng+acc+bs+eco+ip
t_mm=mm*5
per=(tot/t_mm)*100
print("Average is:",per,"%")
if per>=91 and per<=100:
gr='A1'
elif per>=81 and per<=90:
gr='A2'
elif per>=71 and per<=80:
gr='B1'
elif per>=61 and per<=70:
gr='B2'
elif per>=51 and per<=60:
gr='C1'
elif per>=41 and per<=50:
gr='C2'
elif per>=33 and per<=40:
gr='D'
else:
gr="Invalid Grade"
print("The Grade is:",gr)
Output:-
# Program – 2. Write a python program to find the sale price of an item with a given
cost and discount (%).
Source Code:-
cost=float(input("Enter the cost : "))
dis=cost*dis_per/100
sel_price=cost-dis
print("Discount: ",dis)
Output:-
# Program – 3. Write a python program to calculate perimeter/circumference and area
of shapes such as triangle, rectangle, square and circle.
Source Code:-
import math
side=float(input("Enter the side of square:"))
ar_sq=float(side*side)
print("Area of Square:",ar_sq)
peri=float(4*side);
print("Perimeter of square is:",peri)
print()
r=float(input("enter the radius of circle:"))
ar_ci=float(3.14*r*r)
print("Area of circile:",ar_ci)
per_ci=float(2*3.14*r);
print("Perimter of circle is:%.2f"%per_ci)
print()
l=float(input("enter the length of rectangle:"))
b=float(input("enter the breadth of rectangle:"))
ar_rect=float(l*b)
print("Area of rectangle is:",ar_rect)
per_rect=float(2*(l+b))
print("Area of rectangle is:",per_rect)
print()
ba=float(input("enter the base of right angled triangle:"))
h=float(input("enter the height of right angled triangle:"))
ar_tri=float(float((ba*h)/2))
print("Area of triangle is:",ar_tri)
hpt=float(math.sqrt(h*h+ba*ba))
peri_tri=float(h+ba+hpt)
print("Perimter of right angled triangle is:",peri_tri)
Output:-
# Program – 4. Write a program to calculate Simple and Compound interest.
Source Code:-
#input
#process
si = (p*r*t)/100
ci= p * ( (1+r/100)**t - 1)
#output
Output:-
# Program – 5. Write a program to calculate profit-loss for a given Cost and Sell Price.
Source Code:-
cost = float(input("Enter the cost of the product: "))
amt=0
else:
Output:-
# Program – 6. Write a program to calculate EMI for Amount, Period and Interest.
Source Code:-
# driver code
#intereset
r = r / (12 * 100)
#total installments
t = t * 12
Output:-
# Program – 7. Write a program to calculate tax - GST
Source Code:-
op=float(input("Enter original Price:-"))
GST_amt = np - op
Output:-
# Program – 8. Write a program to find the largest and smallest numbers in a list.
Source Code:-
l= []
l.append(ele)
mx = mn = l[0]
mn = l[j]
min_pos = j
mx = l[j]
max_pos = j
Output:-
# Program – 9. Write a python program to find the third largest/smallest number in a
list.
Source Code:-
l = []
n = int(input("Enter the Number of List Elements: "))
for i in range(1, n + 1):
ele = int(input("Please enter the Value of Element%d : " %i))
l.append(ele)
large = l[0]
sec_large = l[0]
third_large = l[0]
for i in l :
if i > large:
third_large = sec_large
sec_large = large
large = i
elif i > sec_large :
third_large = sec_large
sec_large = i
elif i > third_large:
third_large = i
print("Third largest number of the list is:",third_large)
Output:-
# Program – 10. Write a program to find the sum of squares of the first 100 natural
numbers.
Source Code:-
sum1 = 0
for i in range(1, 101):
sum1 = sum1 + (i*i)
print("Sum of squares is : ", sum1)
Output:-
# Program – 11. Write a program to print the first ‘n’ multiples of a given number.
Source Code:-
#input
#computing multiples
multip = range(n, (n * m) + 1, n)
print(list(multip))
Output:-
# Program – 12. Write a program to count the number of vowels in a user entered string.
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
Output:-
# Program – 13. Write a program to print the words starting with a particular alphabet in
a user entered string.
Source Code:-
txt=input("Enter the text:")
for i in txt.split():
if i.startswith(al):
print(i)
Output:-
# Program – 14. Create a dictionary of students to store names and marks obtained in 5
subjects.
Source Code:-
students={'Aksh':[34,46,48,33,47],'Bhavik':[44,45,48,43,42]}
print(students)
Output:-
# Program – 15. Create a dictionary to store names of states and their capitals.
Source Code:-
st={'Gujarat':'Ghandhinagar','Rajasthan':'Jaipur','Bihar':'Patna','Maharashtra':'Mumbai',\
‘Madhya Pradesh':'Bhopal'}
print(st)
Output:-
# Program – 16. Write a program to print the highest and lowest values in the
dictionary.
Source Code:-
my_dict = {'x':500, 'y':5874, 'z': 560}
key_max = max(my_dict.keys())
key_min = min(my_dict.keys())
Output:-
# Program – 17. Write a program to print the number of occurrences of a given alphabet
in a given string.
Source Code:-
# Python Program to Count Occurrence of a Character in a String
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)
Output:-
# Program – 18. Write a program to print Simple Number Triangle Pattern.
Pattern:
1
22
333
4444
55555
Source Code:-
rows = 6
for num in range(rows):
for i in range(num):
print(num, end=' ') # print number
# line after each row to display pattern correctly
print(' ')
Output:-