Xii CS Practicals
Xii CS Practicals
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)
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]
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)
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.
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.
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.
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.
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 #.
Code:
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:
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
Code:
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.
Code:
Output:
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.
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:
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: