You are on page 1of 46

Computer Science

Practical File

Academic Year: 2022-23


Name : Ramesh Vishnoi
School : KV AFS Uttarlai
Class : XII A
Roll no. : 31
2

Index

Aim Page Date Sign

1. To write a python program to 6 12.6.22


search an element in a list and
display the frequency of
elements present in the list
and their location using Linear
search by using a user
defined function.

2. To write a python program to 8 12.6.22


search an element in a list and
display the frequency of
elements present in the list
and their location using binary
search by using a user
defined function.

3. To write a python program to 10 12.6.22


pass a list to a function and
double the odd values and half
even values of a list and
display list elements after
changing.

4. To write a Python program 12 23.6.22


input n numbers in tuple and
pass it to function to count how
3

many even and odd numbers


are entered.

5. To write a Python program to 14 23.6.22


function with key and value,
and update value at that key
in the dictionary entered by the
user.

6. To write a Python program to 16 5.7.22


pass a string to a function and
count how many vowels
present in the string.

7. To write a Python program to 18 5.7.22


generate (Random Number)
that generates random
numbers between 1 and 6
(simulates a dice) using a user
defined function.

8. To write a menu driven python 20 5.7.22


program to implement 10
python mathematical
functions.

9. To write a python program to 23 29.7.22


implement python string
functions.

10. To write a menu driven 25 29.7.22


program in python to delete
the name of a student from the
dictionary and to search phone
no of a student by student
4

name.

11. To write a python program to 27 15.8.22


read and display file content
line by line with each word
separated by #.

12. To write a python program to 29 15.8.22


read a text file and display the
number of consonants,
vowels, uppercase, lowercase
characters in the file.

13. To write a Menu driven 31 16.8.22


program in python to count
spaces, digits, words and lines
from text file TOY.txt

14. To write a python program to 33 25.8.22


remove all the lines that
contain the character „a‟ in a
file and write it to another file.

15. To write a python program to 35 25.8.22


create a binary file with name
and roll number. Search for
a given roll number and
display name, if not found
display appropriate message.

16. To write a python program to 38 27.8.22


create a dictionary with roll
number, name and marks.
Accept 5 records from the user
and write them into a binary
5

file.

17. To write a python program to 40 27.8.22


create a CSV file by entering
user-id and password, read
and search the password for
given user-id.

18. To write a menu driven python 43 27.8.22


program to create a CSV file
by entering dept-id, name
and city, read and search the
record for given dept-id.
6

Practical 1
Aim:Write a python program to search an element in a
list and display the frequency of element present in list and
their location using Linear search by using user defined
function. [List and search element should be entered by
user]
Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:
7

Output 1:

Output 2:

Practical 2
8

Aim:To write a python program to search an element in a


list and display the frequency of element present in list and
their location using binary search by using user defined
function. [List and search element should be entered by user]

Software Used: IDLE(Python 3.8 32-bit)


Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM
Code:

Output 1:
9

Output 2:

Practical 3
10

Aim:To write a python program to pass list to a function


and double the odd values and half even values of a list
and display list element after changing.
Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
11

Output 2:

Output 3:

Practical 4
12

Aim:To write a Python program input n numbers in


tuple and pass it to function to count how many even and
odd numbers are entered.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
13

Output 2:

Output 3:

Practical 5
14

Aim:To write a Python program to function with key


and value, and update value at that key in dictionary
entered by user.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
15

Output 2:

Practical 6
16

Aim:To write a Python program to pass a string to a


function and count how many vowels present in the string.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
17

Output 2:

Output 3:

Practical 7
18

Aim:To write a Python program to generator (Random


Number) that generates random numbers between 1 and
6 (simulates a dice) using user defined function.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
19

Output 2:

Output 3:

Practical 8
20

Aim:To write a menu driven python program to


implement 10 python mathematical functions.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM
Code:

Output 1:
21

Output 2:

Output 3:
22

Practical 9
23

Aim:To write a python program to implement python


string functions.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM

Code:
24

Output:

Practical 10
25

Aim:To write a menu driven program in python to delete


the name of a student from the dictionary and to search
phone no of a student by student name.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM
Code:

Output 1:
26

Output 2:

Output 3:

Practical 11
27

Aim: To write a python program to read and display


file content line by line with each word separated by #.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Text File used:


28

Output:

Practical 12
29

Aim: To write a python program read a text file and


display the number of vowels, consonants, uppercase,
lowercase characters in a file.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM

Code:
30

Text file used:

Output:

Practical 13
31

Aim: To write a Menu driven program in python to count


spaces, digits, words and lines from text file TOY.txt

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse, Hard


disc, RAM

Code:

Text file used:


32

Output:

Practical 14
33

Aim: To write a python program to remove all the lines


that contain the character „a‟ in a file and write it to
another file.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Text file used:


34

Output:

Output Text File Produced:

Practical 15
35

Aim: To write a python program to create a binary file


with name and roll number. Search for a given roll number
and display name, if not found display appropriate
message.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM
Code:

Output 1:
36

Output 2:

Output 3:
37

Practical 16
38

Aim: To write a python program to create a dictionary


with roll number, name and marks. Accept 5 records from
the user and write them into a binary file.

Software Used: IDLE(Python 3.8 32-bit)

Hardware used: Keyboard, Monitor, Mouse,


Hard disc, RAM

Code:

Output 1:
39

Output 2:

Practical 17
40

Aim: To write a python program to create a CSV file by


entering user-id and password, read and search the
password for given user-id.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM

Code:

Output 1:
41

Output 2:

CSV File Produced:


42

Practical 18
43

Aim: To write a menu driven python program to create


a CSV file by entering dept-id, name and city, read and
search the record for given dept-id.
Software Used: IDLE(Python 3.8 32-bit)
Hardware used: Keyboard, Monitor, Mouse, Hard
disc, RAM
Code:

Output 1:
44

Output 2:

Output 3:
45

Output 4:

CSV File Produced:


46

Thank You

You might also like