You are on page 1of 13

COMPUTER SCIENCE

PRACTICAL FILE
2021-2022

NAME: HRIDEY JAIN


CLASS: XI-A
ADMISSION NO: 4092

INDEX
1|Page
Progra Programs Page Signature
m Number
Numbe
r
1. Read two strings and check if string1 is 4
prefix, postfix or nothing from the string2
2. Write a program to read a string and print 5

3. Create menu driven program to encrypt and 6


decrypt
4. Write a program to sort a given list of 7
numbers and print the total number of
operations taking place while sorting the
given list using
i) Bubble Sort
ii) Insertion Sort
5. Write a program which takes 2 digits, X, Y 8
as input and generates a 2-dimensional array.
The element value in the ith row and jth
column of the array should be i*j.
6. Write a program to generate a random 6 9
digits secure OTP. The digits should not
repeat.
7. Write a program to find the second largest 10
number in a given list.

8. Write a program that takes a list of words and 11


creates a dictionary with word as the key and
number of occurrences of the word as the
value.
9. Write a program to create a dictionary of 12
names of flowers as keys and the colours in
which they exist as values in tuples, for
example D={'rose':('red','black','pink'),'lily':
('white','violet')} . Now write a code to print
a) The flower which exists in maximum
number of colors
b) The colour in which most of the flowers
2|Page
exist
10. There are 36 possible combinations, if we 13
throw two dice. A simple pair of loops over
range (6) +1 will enumerate all combinations.
The sum of the two dice is more interesting
than the actual combination. Create
a dictionary of all combinations, using the
sum of numbers on the two dice as the key.
Each value of dictionary will be a tuple with
all possible combination.

PROGRAM 1
Read two strings and check if string1 is prefix, postfix or nothing from the
string2

3|Page
Solution 1:

Output 1:

PROGRAM 2
Write a program to read a string and print

4|Page
Solution 2:

Output 2:

PROGRAM 3
Create menu driven program to encrypt and decrypt
Solution 3:

5|Page
Output 3:

PROGRAM 4
Write a program to sort a given list of numbers and print the total number of
operations taking place while sorting the given list using
i) Bubble Sort

6|Page
ii) Insertion Sort

Solution 4:

PROGRAM 5
Write a program which takes 2 digits, X, Y as input and generates a 2-
dimensional array. The element value in the i th row and jth column of the array
should be i*j.

7|Page
Solution 5:

Output 5:

PROGRAM 6
Write a program to generate a random 6 digits secure OTP. The digits should
not repeat.

Solution 6:
8|Page
Output 6:

PROGRAM 7
Write a program to find the second largest number in a given list.

Solution 7:

9|Page
Output 7:

PROGRAM 8
Write a program that takes a list of words and creates a dictionary with word as
the key and number of occurrences of the word as the value.
Solution 8:

10 | P a g e
Output 8:

PROGRAM 9
Write a program to create a dictionary of names of flowers as keys and the
colours in which they exist as values in tuples, for example D={'rose':
('red','black','pink'),'lily':('white','violet')} . Now write a code to print

11 | P a g e
a) The flower which exists in maximum number of colors
b) The colour in which most of the flowers exist
Solution 9:

PROGRAM 10

Solution 10:

12 | P a g e
13 | P a g e

You might also like