CS PRACTICAL FILE
CS PRACTICAL FILE
Comput
dd er Science
Practical File
SESSION: 2024-2025
SUBMITTED BY: SUBMITTED
TO:
________________ Manju Kalra, PGT (CS)
CLASS :- XII
ROLL NO. :-
1
COMPUTER SCIENCE RECOMMENED
PRACTICAL LIST FOR CLASS XII
TERM
1
1. 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]
2. 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]
3. 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.
4. Write a Python program input n numbers in tuple and pass it to function to count how
many even and odd numbers are entered.
5. Write a Python program to function with key and value, and update value at that
key in dictionary entered by user.
6. Write a Python program to pass a string to a function and count how many
vowels present in the string.
10.Write a python program to read and display file content line by line with each word
separated by #.
11.Write a python program to remove all the lines that contain the character ‘a’ in a
file and write
it to another file.
12.Write a python program to read characters from keyboard one by one, all lower case
letters
gets stored inside a file “LOWER”, all uppercase letters gets stored inside a file
1
“UPPER”, and all other characters get stored inside “OTHERS”
1
13.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.
14.Write a python program to create a binary file with roll number, name and
marks, input a roll number and update the marks.
15.Write a python program to create a CSV file with empid, name and mobile no.
and search empid, update the record and display the records.
TERM2
16.(i)Write a Python program to create Lpush( ) and Lpop( ) function to do push
and pop operation on a stack using a list e.g. take a student information and push and
pop thedetails.(ii)stack using flight details(iii)stack using bank details
17.Create a student table and insert data. Implement the following SQL commands on
the student table:
ALTER table to add new attributes / modify data type / drop attribute
UPDATE table to modify data ORDER By to display data in ascending /
descending order DELETE to remove tuple(s) GROUP BY and find the min,
max, sum, count and average(ii) bank table (iii) flight table(iv) hospital table
18.Integrate SQL with Python by importing the MySQL module record of employee and
display the record.
22.Take a sample of ten phishing e-mails (or any text file) and find most
commonly occurring word(s)
2
2
PRACTICAL-
1
OUTPUT
3
3
PRACTICAL-
2
OUTPUT
4
PRACTICAL-
3
AIM- Write a 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 64-bit)
INPU
T
OUTPU
T
5
PRACTICAL- 4
OUTPUT
6
PRACTICAL- 5
AIM- Write a program to function with key and value, and update value
at that key in dictionary entered by user
INPUT
OUTPUT
7
PRACTICAL- 6
OUTPUT
8
PRACTICAL- 7
OUTPUT(S)
9
PRACTICAL- 8
def Enqueue(Q,item):
Q.append(item)
if len(Q)==1:
front=rear=0
else:
rear=len(
def Dequeue(Q):
if isEmpty(Q):
return "Underflow"
else:
val = Q.pop(0)
if len(Q)==0:
front=rear=None
return val
def Peek(Q):
if isEmpty(Q):
return "Underflow"
else:
front=0
return Q[front]
def Show(Q):
if isEmpty(Q):
print("Sorry No items in Queue ")
else:
t = len(Q)-1
print("(Front)",end
=' ') front = 0
i=front
rear = len(Q)-1
while(i<=rear):
print(Q[i],"==>",end=' ')
i+=1
print()
Q=[ ] #Queue
front=rear=None
while True:
10
print("**** QUEUE DEMONSTRATION ******")
print("1. ENQUEUE ")
print("2. DEQUEUE")
print("3. PEEK")
print("4. SHOW QUEUE ")
print("0. EXIT")
ch = int(input("Enter your choice :"))
if ch==1:
val = int(input("Enter Item to Insert :"))
Enqueue(Q,val)
elif ch==2:
val = Dequeue(Q)
if val=="Underflow":
print("Queue is Empty")
else:
print("\nDeleted Item was :",val)
elif ch==3:
val = Peek(Q)
if val=="Underflow":
print("Queue Empty")
else:
print("Front Item :",val)
elif ch==4:
Show(Q)
elif ch==0:
print("Bye")
break
OUTPUT
11
Enter Item to Insert :20
**** QUEUE DEMONSTRATION ******
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT
Enter your choice :1
Enter Item to Insert :30
**** QUEUE DEMONSTRATION ******
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT
Enter your choice :4
(Front) 10 ==> 20 ==> 30 ==>
**** QUEUE DEMONSTRATION ******
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT
Enter your choice :3
Front Item : 10
**** QUEUE DEMONSTRATION ******
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT
Enter your choice :2
Deleted Item was : 10
**** QUEUE DEMONSTRATION ******
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT Enter
your choice :4
(Front)
20 ==> 30 ==>
12
**** QUEUE DEMONSTRATION ******
12
1. ENQUEUE
2. DEQUEUE
3. PEEK
4. SHOW QUEUE
0. EXIT
Enter your choice :0
Bye
13
PRACTICAL- 9
OUTPUT
14
PRACTICAL- 10
AIM- Write a program to read and display file content line by line
with each word separated by #.
OUTPUT
15
PRACTICAL- 11
AIM- Write a program to remove all the lines that contain the
character ‘a’ in a file and write it to another file.
OUTPUT
16
PRACTICAL- 12
INPUT
CRL\
OUTPUT
17
PRACTICAL- 13
AIM- Write a 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
INPUT
OUTPUT
18
PRACTICAL- 14
AIM- Write a program to create a binary file with roll number, name
and marks, input a roll number and update the marks.
OUTPUT
19
PRACTICAL- 15
AIM- Write a program to create a CSV file with empid, name and
mobile no. and search empid, update the record and display the
records
INPUT
20
OUTPUT
21
PRACTICAL- 16
22
OUTPUT
23
PRACTICAL- 17
DELETE to remove tuple(s) GROUP BY and find the min, max, sum, count and
average
use studentdb;
Database changed
CREATING TABLE
desc student;
INSERTING VALUE
desc student;
UPDATING VALUE
25
update student set Percentage = 55 where roll = 6;
desc student;
desc student;
ORDER BY COMMAND
26
AVERAGE COMMAND
COUNT COMMAND
27
PRACTICAL- 18
INPUT
OUTPUT
28
PRACTICAL- 19
INPUT
OUTPUT
29
PRACTICAL- 20
INPUT
OUTPUT
30
PRACTICAL- 21
INPUT
OUTPUT
31
PRACTICAL- 22
INPUT
OUTPUT
32