0% found this document useful (0 votes)
18 views44 pages

XII CS Pract Sample

Uploaded by

rin3.4.3.5.17
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)
18 views44 pages

XII CS Pract Sample

Uploaded by

rin3.4.3.5.17
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/ 44

2

Page Date Sign


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


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


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


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

5. To write a Python program to 14


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


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

7. To write a Python program to 18


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


program to implement 10
python mathematical functions.

9. To write a python program to 23


implement python string
functions.

10. To write a menu driven 25


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 27


read and display file content
4

line by line with each word


separated by #.

12. To write a python program to 29


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

13. To write a Menu driven 31


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

14. To write a python program to 33


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


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


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 40


create a CSV file by entering
5

user-id and password, read


and search the password for
given user-id.

18. To write a menu driven python 43


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

Practical 1
6

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

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

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:
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:
40

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:
41

Output 1:

Output 2:
42

CSV File Produced:


43

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:
44

Output 1:

Output 2:
45

Output 3:

Output 4:

CSV File Produced:

You might also like