Final Practical Cs 2025
Final Practical Cs 2025
CODE: -
11= eval (input ("enter the list elements: "))
length = Len (11)
element = int (input ("enter the element to be searched for: "))
for i in range (0, length):
if element == 11[i]:
print (element, found at index',i)
break
else:
print (element, 'not present in the given list')
z
Practical:-2
Code: -
WTemp = ['Mon', 45, 'Tue', 43, 'Wed', 42, 'Thu', 40, 'Fri', 38, 'Sat', 40, 'Sun',38]
ln=len (WTemp)
Days = []
Degrees = []
for i in range (ln):
if (i % 2) == 0:
Days. Append (WTemp[i])
else:
Degrees.append (WTemp[i])
print ("Original list is: ", WTemp)
print ("The days are: ", Days)
print ("The temperatures are: ", Degrees)
Practical: -3
Q: -3 BUBBLE SORT
Code: -
def main ():
def main ():
l= [42,29,74,11,65,58,]
n=Len(l)
print ('original list is:',l)
for i in range(n-1):
for j in range (n-1-i):
if l[j]> l[j+1]:
l[j], l[j+1] =l[j+1], l[j]
print ("list after sorting is: ",l)
main ()
Practical: -4
Q: -4 INSERTION SORT
CODE:-.
Practical: -5
Q: -5 FIND THE HIGHEST AND LOWEST NUMBER IN A USER INPUT
LIST
Code: -
lst=[]
Num=int (input ("how many numbers: "))
for n in range (Num):
Num =int (input ('enter number; ‘))
lst.append(num)
print ('maximum element in the list is: ‘, max(lst))
print ('minimum element in the list is: ‘, min(lst))
Practical:6
Q: -6 WPA TO STORE RECORD OF STUDENTS IN TUPLE AND PRINT
THEM
CODE: -
st=((200, "Harmeet", 88), (201, "Deepika", 98), (202, "Radhika", 78), (204,
"Shaurya", 90))
print ("S_No"," Roll No"," Name"," Marks")
for i in range (0, len (st)):
print((1+1),'\t',st[i][0],'\t',st[i][1],'\t',st[i][2])
Practical: -7
Q: -7 WPA TO INPUT ANY TWO TUPLES AND SWAP THEIR
VALUES
CODE: -
Practical: - 8
Q: -8 WPA TO ENTER NAMES OF EMPLOYEES AND THEIR SALARIES
AS INPUT AND
STORE THEM IN A DICTIONARY
CODE: -
num = int (input ("Enter the number of employees whose data to be stored salary: "))
count = 1
employee = dict()
while count <= num:
name = input ("Enter the name of the Employee: ")
salary = int (input ("Enter the salary: "))
employee [name] = salary
count += 1
print("\n\nEMPLOYEE_NAME\tSALARY")
fork in employee:
print (k, '\t\t',employee[k])
Practical: -9
Q: -9 WPA A PROGRAM TO COUNT THE NUMBER OF TIMES A
CHARACTER APPER IN
GIVEN STRING USING A DICTONARY
CODE: -
str = input ("Enter a string: ")
dict1= {}
for ch in str:
if ch in dict1:
dict1[ch]+=1
else:
dict1[ch]=1
for key in dict1:
print(key,':’, dict1[key])
Practical: -10
Q:-10 WAP FOR REVERSING A TUPLE
Code: -
tup= (10,20,30,40,50)
print ("original tuple is ")
for i in range (0, len(tup)):
print(tup[i])
print ("tuple in reverse”)
for j in range (len(tup)-1, -1, -1):
print(tup[j])
Practical: -11
Q: -11 WAP PROGRAM TO INPUT ‘N’ NAMES AND PHONE NO TO
STORE IT IN A
SICTIONARY AND PRINT THE PH. NO. OF A PATICULAR
NAME
CODE: -
phone=dict()
i=1
n=int (input("Enter number of entries:"))
while i<=n:
a=input ("Enter Name:")
b=input ("Enter Phone no:")
phone [a]=b
i = i+1
l = phone.keys()
x=input ("Enter name to be searched:")
for i in l:
if i==x:
print (x,": phone no is:",phone[i])
break
else:
print (x, "does not exist")
Practical: -12
CODE: -
Practical: -13
Q: - 13 CIRCLE MODULE
Code: -
import math
def area(radius):
return int (math.pi* radius*radius)
def circumference(radius):
return int (math.pi * 2 * radius)
r=5
print ("Area of circle is:", area(r))
print ("Area of circumfrence is:", circumference(r))
Practical: -14
Code: -
from random import randint
def fill_list(lst, limit, low,high):
for i in range(limit):
lst.append(randint(low,high))
minimum = int (input ("Min: "))
maximum = int (input ("Max: "))
n = int (input ("Numbers limit: "))
a= []
fill_list(a,n,minimum,maximum)
print(a)
Practical: -15
CODE: -
def cal_Mean(list1):
total = 0
count = 0
for i in list1:
total += i
count += 1
mean = total / count
print ("The calculated mean is:", mean)
list1 = [2.6,3.4,8.5,7.9]
cal_Mean(list1)