COMPUTER SCIENCE PRACTICAL FILE Page |1
COMPUTER SCIENCE (083)
PRACTICAL FILE
SESSION : 2024-25
Made by:
Name:-Tanmay Doharey
Class:-XI-D
Roll No:-33
DPS Indirapuram
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |2
INDEX
S.NO. AIM PAGE NO. SIGNATURE
1. Write a program to create a dictionary having
frequency of each word of the string. Page 3
2. Write a program to print all elements in a list those
have only single occurrence. Page 4
3. Write a program to enter names of employees and
their salaries as input and store them in a dictionary. Page 5
4. Write a program to read 6 numbers and create a
dictionary having keys EVEN and ODD. Page 6
5. Write a program that reads string from user. Your
program should create a dictionary having key as word
length and value is count of words of that length.
Page 7
6. Write a program to input roll numbers and their
names of students of your class and store them in the
dictionary as the key-value pair. Perform the following
operations on the dictionary: a) Display the Roll Page 8
numbers and name for all students. b) Add a new key-
value pair in this dictionary and display the modied
dictionary c) Delete a particular student's record from
the dictionary d) Modify the name of an existing
students.
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |3
Aim 1:
Write a program to create a dictionary having frequency of each word of the
string.
CODE:
a=input("Enter string:")
l=a.split()
y={}
for i in l:
x=a.count(i)
y.update({i:x})
print(y)
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |4
Aim 2:
Write a program to print all elements in a list those have only single
occurrence.
CODE:
a=int(input("Enter total numbers you want to add in list:"))
x={}
for i in range(a):
b=int(input("Enter number:"))
if b in x:
x.update({b:x[b]+1})
else:
x.update({b:1})
print(x)
for j in x:
if x[j]==1:
print(j,end=' ')
else:
pass
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |5
Aim 3:
Write a program to enter names of employees and their salaries as input and
store them in a dictionary.
CODE:
a=int(input("Enter number of entries you wish to make:"))
x={}
for i in range(a):
b=input("Enter employee name:")
c=int(input("Enter employee salary:"))
x.update({b:c})
print(x)
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |6
Aim 4:
Write a program to read 6 numbers and create a dictionary having keys EVEN
and ODD.
CODE:
x=[]
y=[]
for i in range(6):
a=int(input("Enter number:"))
if a%2==0:
x+=[a]
else:
y+=[a]
b={}
b.update({'EVEN':x,'ODD':y})
print(b)
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |7
Aim 5:
Write a program that reads string from user. Your program should create a
dictionary having key as word length and value is count of words of that length.
CODE:
a=input("Enter string:")
l=a.split()
x={}
for i in l:
s=len(i)
if s in x:
x.update({s:x[s]+1})
else:
x.update({s:1})
print(x)
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |8
Aim 6:
Write a program to input roll numbers and their names of students of your
class and store them in the dictionary as the key-value pair. Perform the
following operations on the dictionary: a) Display the Roll numbers and name
for all students.
b) Add a new key-value pair in this dictionary and display the modified
dictionary
c) Delete a particular student's record from the dictionary
d) Modify the name of an existing students.
CODE:
a=int(input("Enter how many enetries:"))
x={}
for i in range(a):
b=int(input("Enter roll number:"))
c=input("Enter name:")
x.update({b:c})
while True:
d=int(input("Enter 1 to display, 2 for adding a new entry, 3 for
deleting an existing entry, 4 to modify an entry and 0 to exit:"))
if d==1:
print(x)
elif d==2:
e=int(input("Enter roll number:"))
f=input("Enter name:")
x.update({e:f})
print(x)
elif d==3:
g=int(input("Enter the roll number you want to delete:"))
if g in x:
del x[g]
print(x)
else:
print("Roll number doesn't exist")
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D
COMPUTER SCIENCE PRACTICAL FILE Page |9
elif d==4:
h=int(input("Enter the roll number you want to modify the
details for:"))
if h in x:
i=input("Enter new name:")
x.update({h:i})
print(x)
else:
print("Roll number doesn't exist")
elif d==0:
break
else:
print("Input doesn't exist")
OUTPUT:
TANMAY DOHAREY SESSION:-2024-25 CLASS:XI-D