0% found this document useful (0 votes)
3 views43 pages

Xii CS Practicals

The document outlines a series of practical Python programming exercises aimed at various tasks such as searching elements in lists, manipulating data structures, and file handling. Each practical includes the aim, software and hardware used, and expected outputs. The exercises cover topics like linear and binary search, string manipulation, and creating CSV and binary files.

Uploaded by

ad9685481096
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views43 pages

Xii CS Practicals

The document outlines a series of practical Python programming exercises aimed at various tasks such as searching elements in lists, manipulating data structures, and file handling. Each practical includes the aim, software and hardware used, and expected outputs. The exercises cover topics like linear and binary search, string manipulation, and creating CSV and binary files.

Uploaded by

ad9685481096
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Index

Page Date Sign


Aim
1. To write a python program to 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 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 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 input n


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

5. To write a Python program to


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 pass a


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

7. To write a Python program to


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


program to implement 10 python
mathematical functions.

9. To write a python program to


implement python string functions.

10. 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.

11. To write a python program to read


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

12. To write a python program to read a


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

13. To write a Menu driven program in


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

14. To write a python program to 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 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 create


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

17. 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.

18. 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.
4

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:

Output 1:
5

Output 2:
6

Practical 2
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:
7

Output 2:
8

Practical 3
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:
9

Output 2:

Output 3:
10

Practical 4
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:
11

Output 2:

Output 3:
12

Practical 5
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:
13

Output 2:
14

Practical 6
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:

Output 2:
15

Output 3:
16

Practical 7
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:
17

Output 2:

Output 3:
18

Practical 8
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:
19

Output 2:

Output 3:
20
21

Practical 9
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:

Output:
22
23

Practical 10
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:
24

Output 2:

Output 3:
25

Practical 11
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:


26

Output:
27

Practical 12
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:

Text file used:


28

Output:
29

Practical 13
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:


30

Output:
31

Practical 14
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:


32

Output:

Output Text File Produced:


33

Practical 15
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:
34

Output 2:

Output 3:
35
36

Practical 16
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:
37

Output 2:
38

Practical 17
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:
39

Output 2:

CSV File Produced:


40
41

Practical 18
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:
42

Output 2:

Output 3:
43

Output 4:

CSV File Produced:

You might also like