You are on page 1of 12

MANAV RACHNA INTERNATIONAL

SCHOOL, NOIDA

COMPUTER SCIENCE
PRACTICAL FILE - TERM 2

Student Name:
Ayaan Sehgal
Grade: XI Einstein
Roll No:06
Session:2021-22
P a g e 1 | 12
Manav Rachna International School, Noida
Session: 2021 – 22

Certificate

This is to certify that the content of this Practical File by Ayaan Sehgal is the
bone fide work of him/her submitted to Manav Rachna International School,
Noida for consideration in partial fulfillment of the requirement of Central
Board of Secondary Education, Delhi.

The original research work was carried out by him/her under the supervision of
Ms. Ritika Singh in the academic year 2021-22. On the basis of the declaration
made by him/ her, I recommend this practical report for evaluation.

Signature of the Examiner Signature of the Principal

Signature of the Teacher School Stamp

P a g e 2 | 12
Manav Rachna International School, Noida
Session: 2020 – 21

Acknowledgement

I would like to express my sincere gratitude to my friends, mentors and


teachers for providing their invaluable guidance, comments and suggestions
throughout the completion of the practical work. I would especially like to
thank my computer science teacher Ms. Ritika Singh for mentoring me to
complete this assignment and clarifying my doubts I faced during the
completion of this project.

I would also like to express my gratitude to respected Principal ma’am Ms.


Nindiya Saket and HM ma’am Ms. Priyanka Singh for providing me all
facilities and great opportunities to learn.

P a g e 3 | 12
Index

S. No Program Page No. T.


Signature
1 delete/remove all the 5
odd numbers from the
list
2 to search for an 6
element in a given list
3 Modify this list so that it does 6,7
not contain any duplicate
elements.

4 Write a program to 7
read names and
percentage
5 Write a program to 7,8
read names and
percentage
6 Write a program that 8
convert a string to a
tuple and checks the
frequency of each
element in tuple.
7 a list of words and you 8
want to sort them
according to the
number of their
characters
8 remove an element at index 3 9
and display the updated tuple.

9 Create a menu-based 9,10


program to perform
the above-mentioned
operations
10 Write a Python 11,12
P a g e 4 | 12
program to calculate
the changed median
value and average
temperature

Q1-Write a program to delete/remove all the odd numbers from the


list. L=[23,3,12,8,19,54,10,67]

CODE-

L=[23,3,12,8,19,54,10,67]
for i in L:
if i%2!=0:
L.remove(i)
print(L)

OUTPUT:

Q2-Write a program to search for an element in a given list


of numbers.

CODE:
a=[1,2,3,4,5,6]
b=int(input('element you want to check:'))
for i in a:
if b==i:
print('index no of selected elements:',a.index(i))

OUTPUT:

P a g e 5 | 12
Q3-Write a program to read a list of elements. Modify this list so that it
does not contain any duplicate elements.

CODE:
x = [1,2,3,4,3,2,1,4,5,6,7,7,8,9,8]
y = []
print('list before removing duplicate elements',x)
for i in x:
if i not in y:
y.append(i)
print('List after removing all duplicate elements',y)

OUTPUT:

Q
4- Write a program to read names and percentage of four students and
create a dictionary from it having names as keys. Display the dictionary.

CODE:
name=dict()
n=int(input('number of enters you want:'))
i=1
while i<=n:
a=input('Name of student:')
b=input('Percentage of student:')
name[a]=b
P a g e 6 | 12
i=i+1
print('name of student','\t','percentage of student')
for i in name:
print(i,name[i],'%')
print('in dictionary form',cname)
OUTPUT:

Q5- Write a program to read names and percentage.


CODE:
a = {'ayaan':10,'adi':2,'archit':12}
sum=1
for i in a:
sum=sum*a[i]
print(sum)

OUTPUT:

Q6- Write a program that convert a string to a tuple and checks the
frequency of each element in tuple.
CODE:
a='all well if it ends well'
b=tuple(a.split( ))
print(b.count('well'))

P a g e 7 | 12
OUTPUT:

Q7-Suppose you have a list of words and you want to sort them
according to the number of their characters in descending order. Write
a Python program to do the same.

CODE:
def sort(x):
x.sort(key=len,reverse=True)
return x
x=['ayaan','adi','archit','kishlay']
print(sort(x))

OUTPUT:

Q8-Write a program to create a tuple (2,3,4,5,6,7,8,9). Now, remove an


element at index 3 and display the updated tuple.

CODE:
= {'Ayaan':1,'adi':2}
if (len(a) == 0):
print('The Dict is empty.')
else:
print('The Dict is not empty.')

OUTPUT:

P a g e 8 | 12
Q9- Write a program to accept and store Employee name as a key and
his salary, allowance and deduction as value in a Dictionary Dict for 10
employees. Display the following Menu:
a. Display Total Salary
b. Dispay Total allowance and deductions
c. Search an employee
Create a menu-based program to perform the above-mentioned
operations.

CODE:
x=dict()
i=1
count=0
n=int(input('Enter the no. of enteries:'))
while count<=n:
a=input('name of emplyee :')
b=input('Enter Salary:')
c=input('Enter Deduction')
d=float(input('Enter the allowaance'))
e=(a,b,c)

P a g e 9 | 12
x[a]=e
count=count+1
f=x.keys()

f=input('do you want to search the list or the employee:')


if f== 'list':
print(list(x))
elif f=='search':
y=input('Name of the employee you want to search:')
if y in x:
print(a,b,c,d)
OUTPUT:

Q10-Consider the temperature given below for the month of June in

P a g e 10 | 12
North India. Calculate the average temperature and median value. This
temperature gets dipped with a variation of 20° C in the month of
December. Write a Python program to calculate the changed median
value and average temperature.
Location Temperature
Delhi 41
Shimla 32
Chandigar 43
h
Rohtak 40
Srinagar 28

CODE:
import statistics as s

B=[41,32,43,40,28,45]

print('data OF :',B)

print('for month of June:',int(s.mean(B)))

print('median value :',int(s.median(B)))

C=[]

for i in C:

C=C+[i -20]

P a g e 11 | 12
print ('for month of December:',int(s.mean(C)))

print ('median value of :',int(s.median(C)))

OUTPUT:

P a g e 12 | 12

You might also like