CO-OPERATIVE PUBLIC SCHOOL
THODUPUZHA
Aff. No. 930753
PRACTICAL RECORD BOOK
XII
COMPUTERSCIENCE
2024-2025
1
CO-OPERATIVE PUBLIC SCHOOL
THODUPUZHA
PRACTICALRECORDBOOK
XII
COMPUTER SCIENCE
2024-
2025
Certified that this was the record of Bonafide practical work carried
out by ............................................................................................................
Reg. No. ........................................... of Class XII in this school during
the year2024-
2025.
Teacher In charge Principal Examiner
Date:
2
INDEX
SI PG
NO DATE NAME OF THE EXPERIMENT NO
1 PRIME NUMBER GENERATOR 4
2 SECOND LARGEST ELEMNT
3 FIBONACCI SERIES
4 SUM OF SERIES
5 LIST: LEFT SHIFT
6 STACK OPERATIONS
7 STRING REVERSAL USING STACK.
8 MANAGING DIRECTORY
INFORMATION
9 BUBBLE SORT
10 CONVERTING 1ST LETTER TO UPPER
CASE
11 FREQUENCY OF LIST ELEMENTS
12 TEXT FILE 1
13 TEXT FILE 2
14 TEXT FILE 3
15 BINARY FILE
16 CSV FILE
17 DATA BASE MANAGEMENT
18 PYTHON-MYSQL DATABASE
CONNECTIVITY 1-INSERT
19 PYTHON-MYSQL DATABASE
CONNECTIVITY 2-UPDATE
20 PYTHON-MYSQL DATABASE
CONNECTIVITY 3-DELETE
3
1. PRIME NUMBER GENERATOR
AIM: To generate all prime number between the range n1 and n2
(inputted by the user)
Source Code:
Output:
SCREEN SHOT
4
2. SECOND LARGEST ELEMNT
AIM: To find the second largest elemnt in a list
Source Code:
Output:
SCREEN SHOT
5
3. FIBONACCI SERIES
AIM: To print Fibonacci series
Source Code:
Output:
SCREEN SHOT
6
4. SUM OF SERIES.
AIM: To find the sum of series S=x+(x^2)/2!+(x^3)/3!+……+
(x^n)/n!
Source Code:
x=int(input("enter base no"))
n=int(input("enter the limit of series"))
s=0
f=1
for i in range(1,n+1):
f=f*i
p=x**i
s=s+p/f
print(s)
Output:
7
SCREEN SHOT
[Link]: LEFT SHIFT
AIM: To input a list and a numeric value and shift the element in the
list to left by the numeric value
Source Code:
L=eval(input("enter your list of numbers"))
k=int(input("enter no of position to shift"))
for i in range(k):
p=L[-1]
8
for j in range(len(L)):
L[j-1]=L[j]
L[-2]=p
print("updated list is:",L)
Output :
SCREEN SHOT
9
6. STACK OPERATIONS
AIM: A ,menu driven program to insert ,delete and display on a stack
Source code:
10
Output:
SCREEN SHOT
7. STRING REVERSAL USING STACK.
Aim: A line of text is read from input terminal into a stack and display the
string in reverse order.
Source code:
def PUSH(stk,item):
[Link](item)
TOP=len(stk)-1
def POP(stk):
item=[Link]()
11
return item
stk=[]
TOP=None
string=input("enter the string to be reversed")
for i in string:
PUSH(stk,i)
while len(stk)!=0:
item=POP(stk)
print(item,end='')
OUTPUT
SCREEN SHOT
12
8. Managing Directory Information
Aim: To manage the linear stack called directory with the following
information: city name and pin code
Source code:
13
OUTPUT
SCREEN SHOT
9. BUBBLE SORT
AIM: To sort a list of elements in ascending order using bubble sort.
Source code:
L=eval(input("enter a list"))
n=len(L)
for i in range(n-1):
for j in range(n-i-1):
if L[j]>L[j+1]:
L[j],L[j+1]=L[j+1],L[j]
print("sorted list is:",L)
14
OUTPUT
SCREEN SHOT
15
10. CONVERTING 1ST LETTER TO UPPER CASE
AIM: To convert first letter of each word in a string to upper case
Source Code:
x=input("enter a sentence")
y=[Link]()
z=[]
for i in y:
a=i[0].upper()+i[1: ]
[Link](a)
b=''.join(z)
print(b)
16
Output:
SCREEN SHOT
[Link] OF LIST ELEMENTS
AIM: To find the frequency of each element and to display a list of
unique and duplicate elements
Source Code:
17
Output:
SCREEN SHOT
[Link] FILE 1
AIM: To read the contents of text file and display words having
exactly four characters.
Source Code:
18
Output:
SCREEN SHOT
13. TEXT FILE 2
AIM: To count the number of vowels in text file.
Source Code:
19
Output:
SCREEN SHOT
14. TEXT FILE 4
AIM: To remove all lines that contain the character ‘a’ in a file and
write it to another file.
Source Code:
20
Output:
SCREEN SHOT
15. BINARY FILE
AIM: A program to update mark in a binary file.
Source Code:
21
Output:
SCREEN SHOT
[Link] FILE
AIM: Password verification using csv file having user-id and
password
Source Code:
22
Output:
SCREEN SHOT
[Link] MANAGEMENT
Aim : A collection of programs used for managing data and
simultaneously it supports different type of users to create, manage,
retrieve, update and store information.
1. Database creation
Command:
create database database ename;
Output :
23
SCREEN SHOT
2. Open database
Command :
use databasename;
Output:
SCREEN SHOT
3. Table creation
Command:
create table tablename(<column1><data type>[(<size>)],
<column2><data type>[(<size>)……]);
Output:
SCREEN SHOT
4. Table data insertion
Command:
insert into<tablename>[<column list>]
values(<value>,<value>,<value>…..)
output:
24
SCREEN SHOT
5. Retrieve data from table
Command:
Select column name from table name;
Output:
SCREEN SHOT
6. Alter tables structure (add column)
Command:
Alter table <table name> ADD <column name><data
type><size> [<constraint name >];
SCREEN SHOT
7. Alter table structure(modify column definition)
Command:
Alter table<table name>
Modify(columnname newdatatype(newsize))[FIRST|
AFTER column];
Output:
SCREEN SHOT
8. Alter table structure(change column name)
25
Command:
Alter table change [column] old_col_name
column_defenition;
Output:
SCREEN SHOT
9. Modify Data
Command:
Update table name set column name=value where condition;
Output:
SCREEN SHOT
10. Deleting Data
Command:
Deletefrom table name where condition;
Output:
SCREEN SHOT
26
11. Order By
Command:
Select column list from tablename order by column name;
Output:
SCREEN SHOT
12. Group By
Command:
Select column list from table name group by column name;
Output:
SCREEN SHOT
18. PYTHON-MYSQL DATABASE CONNECTIVITY 1-
INSERT
Aim: write a program to connect with python with MYSQL using
database connectivity and perform the following operations on data in
database: create, insert data and select.
A. Create a table
27
Output:
SCREEN SHOT
B. Insert the Data
Output:
SCREEN SHOT
C. Select the data
Output:
SCREEN SHOT
19. PYTHON-MYSQL DATABASE CONNECTIVITY 1-
UPDATE
Aim: write a program to connect with python with MYSQL using
database connectivity and perform the following operations on data in
database: update
A. Update the table
28
Output:
SCREEN SHOT
20. PYTHON-MYSQL DATABASE CONNECTIVITY 1-
UPDATE
Aim: write a program to connect with python with MYSQL using
database connectivity and perform the following operations on data in
database: delete
A. Delete the table
29
Output:
SCREEN SHOT
30