0% found this document useful (0 votes)
13 views45 pages

CBSE Class 12 Computer Science Practical File

Uploaded by

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

CBSE Class 12 Computer Science Practical File

Uploaded by

shivamgupta98119
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DELHICITYSCHOOL

SESSION–2025-2026

CENTRAL BOARD OF SECONDARY EDUCATION


PRACTICAL FILE OF COMPUTER SCIENCE (083)

SUBMITTEDBY- SUBMITTED TO-


Student’s Name MS. PINKI

12TH, A
ACKNOWLEDGEMENT
I wish to express my deep sense of gratitude and
in debtedness to our learned teacher Ms. Pinki ,
PGT COMPUTER SCIENCE, Delhi City School for
her in valuable help, advice and guidance in the
preparation of this project.

I am also greatly indebted to our principal


[Link] Kohli and school authorities for providing
me with the facilities and requisite laboratory
conditions for making this practical file.

I also extend my thanks to a number of teachers ,


my classmates and friends who helped me to
complete this practical file successfully.

Students
Name
CERTIFICATE
This is to certify that Students name, student
of Class XIIA, Delhi City School has completed
the PRACTICAL FILE during the
academicyear2025-2026 towards partial
fulfillment of credit for the computer science
practical evaluation of CBSE and submitted
satisfactory report, as compiled in the
following pages, under my supervision.
Total number of practical certified are:

Examiner Signature

Head of the Department

Signature Principal

Signature
[Link]. Practical Date Teacher’s
signature
1 CREATING A MENU DRIVEN PROGRAM TO PERFORM
ARITHMETIC OPERATIONS

2 CREATING APYTHON PROGRAM TODISPLAY FIBONACCI


SERIES

3 CREATING A MENU DRIVEN PROGRAM TO FIND


FACTORIAL AND SUM OF LIST OF NUMBERS USING
FUNCTION.
4 CREATINGAPYTHONPROGRAMTOIMPLEMENT
MATHEMATICAL FUNCTIONS

5 CREATING A PYTHON PROGRAM TO GENERATE


RANDOM NUMBER BETWEEN 1 TO 6

6 CREATING A PYTHON PROGRAM TO READ A


TEXT FILE LINE BY LINE AND DISPLAY
EACH WORD SEPARATED BY '#'

7 CREATING A PYTHON PROGRAM TO READ A


TEXT FILE AND DISPLAY THE NUMBEROF
VOWELS/CONSONANTS/LOWERCASE/ UPPER
CASECHARACTERS.

8 CREATING A PYTHON PROGRAM TO COPY


PARTICULARLINESOFATEXTFILEINTOAN
ANOTHER TEXT FILE

9 CREATING A PYTHON PROGRAM TO CREATE


AND SEARCH RECORDS IN BINARY FILE

10 CREATING A PYTHON PROGRAM TO CREATE


AND UPDATE/MODIFY RECORDS INBINARY
FILE

11 CREATING A PYTHON PROGRAM TO CREATE AND


SEARCHI EMPLOYEE’S RECORDIN CSV FILE.

12 CREATING A PYTHON PROGRAM TO IMPLEMENT


STACK OPERATIONS

13 CREATINGAPYTHONPROGRAMTO
INTEGRATEMYSQLWITHPYTHON
(INSERTINGRECORDSANDDISPLAYING
RECORDS)

14 CREATINGAPYTHONPROGRAMTOINTEGRATE
MYSQL WITH PYTHON(SEARCHING AND
DISPLAYING RECORDS)

15 CREATING A PYTHON PROGRAM TO INTEGRATE


MYSQL WITH PYTHON(UPDATING RECORDS)

16 SQL COMMANDS EXERCISE 1

17 SQL COMMANDS EXERCISE 2

18 SQL COMMANDS EXERCISE 3

19 SQL COMMANDS EXERCISE 4


PROGRAM1: CREATING A MENU DRIVEN PROGRAM TO PERFORM
ARITHMETIC OPERATIONS

AIM: To write a menu driven Python Program to perform Arithmetic


operations(+, -*,/)based on the user’s choice.

SOURCECODE:

Result: Thus, the above Python program is executed successfully and


the output is verified.
SAMPLEOUTPUT:
Python Program Executed
Output:

Run–1:

Run-2:

*************************************************************************************
Program2 CREATING A PYTHON PROGRAM TO
DISPLAY FIBONACCI SERIES

AIM: To write a Python Program to display Fibonacci Series up to ‘n’


numbers.

SOURCECODE:

Result: Thus, the above Python program is executed successfully and


the output is verified.
SAMPLEOUTPUT:
Python Executed Program
Output:

RUN-1:

RUN-2:

*****************************************************************************************
Program 3 CREATING A MENU DRIVEN PROGRAM TO FIND
FACTORIAL AND SUM O FLIST OF NUMBERS USING FUNCTION.

AIM:
To write a menu driven Python Program to find Factorial and
sum of list of numbers using function.
SOURCECODE:

Result: Thus, the above Python program is executed successfully and


the output is verified.
SAMPLEOUTPUT:
Python Executed Program
Output:

RUN-1:

RUN–2:

**************************************************************************************
Program 4 CREATING A PYTHON PROGRAM TO IMPLEMENT
MATHEMATICAL FUNCTIONS

AIM:To write a Python program to implement python mathematical


functions to find:
(i) To find Square of a Number.
(ii) To find Log of a Number(i.e.,Log10)
(iii) To find Quad of a Number

SOURCECODE:

Result: Thus , the above Python program is executed successfully and


the output is verified.
SAMPLEOUTPUT:
Python Executed Program
Output:

**************************************************************************************
Program5 CREATING A PYTHON PROGRAM TO GENERATE
RANDOM NUMBER BETWEEN 1 TO 6

AIM:
To write a Python program to generate random number
between 1 to 6 to simulate the dice.

SOURCE CODE:

Result: Thus ,the above Python program is executed successfully and


the output is verified.
SAMPLEOUTPUT:
Python Executed Output Program:

**************************************************************************************
Program6

CREATING A PYTHON PROGRAM TO READ A TEXT FILELINE


BY LINE ANDDISPLAY EACH WORD SEPARATED BY '#'

AIM: TowriteaPythonProgramtoReadatextfile"[Link]"lineby line


and displayeach word separated by '#'.

SOURCECODE:

Result:Thus,theabovePythonprogramisexecutedsuccessfullyand the
output is verified.
SAMPLEOUTPUT:
[Link]:

***************************************************************************************
Program7

CREATING A PYTHON PROGRAM TO READ A TEXT FILE


AND DISPLAY THE NUMBER OF
VOWELS/CONSONANTS/LOWER CASE/ UPPER CASE
CHARACTERS.
AIM:To write a Python Program to read a text file "[Link]" and
displays the number of Vowels/ Consonants/ Lowercase /
Uppercase/characters in the file.

SOURCECODE:

Result:Thus,theabove Pythonprogramisexecutedsuccessfullyand the


output is verified.
SAMPLEOUTPUT:
[Link]:

***************************************************************************************
Program8

CREATINGAPYTHONPROGRAMTOCOPYPARTICULARLINES OF
A TEXT FILEINTO AN ANOTHER TEXT FILE

AIM: To write a python program to read lines from a text file


"[Link]"andcopythoselinesintoanotherfile whicharestarting with an
alphabet 'a' or 'A'.

SOURCECODE:

Result:Thus,theabove Pythonprogramisexecutedsuccessfullyand the


output is verified.
SAMPLEOUTPUT:
PythonExecutedProgram
output:[Link]:

PythonExecutedProgramOutput:

[Link]:

*****************************************************************************************
Program9
CREATINGAPYTHONPROGRAMTOCREATEANDSEARCH RECORDS
IN BINARY FILE

AIM: To write a Python Program to Create a binary file with roll


[Link]
thename,ifnotfounddisplayappropriatemessage.

SOURCECODE:

Result:Thus,theabove Pythonprogram isexecutedsuccessfullyand the


output is verified.
SAMPLEOUPUT:
PYTHONPROGRAMEXECUTEDOUTPUT:

*******************************************************************************************
Program10

CREATINGAPYTHONPROGRAMTOCREATEAND UPDATE/MODIFY
RECORDS INBINARY FILE
AIM:
TowriteaPythonProgramtoCreateabinaryfilewithroll
number,name,markandupdate/modifythe markfor a given roll
number.
SOURCECODE:

Result:Thus,theabovePythonprogram isexecutedsuccessfullyand the


output is verified.
SAMPLEOUTPUT:
PYTHONPROGRAMEXECUTEDOUTPUT:

**********************************************************************************
Program11

CREATINGAPYTHONPROGRAMTOCREATEANDSEARCHI
EMPLOYEE’SRECORDINCSVFILE.

AIM: TowriteaPythonprogramCreateaCSVfiletostore Employ,


Name, Salary and search any Employee and display Name,
Salaryandifnotfounddisplayappropriatemessage.
SOURCECODE:

Result:Thus,theabovePythonprogram isexecutedsuccessfullyand the


output is verified.
SAMPLEOUTPUT:
PYTHONPROGRAMEXECUTEDOUTPUT:

******************************************************************************
Program12CREATINGAPYTHONPROGRAMTOIMPLEMENT STACK
OPERATIONS

AIM:Towriteapythonprogramtoimplementstackusingalistdatastructure
SOURCECODE:

Result:Thus,theabovePythonprogram isexecutedsuccessfullyand the


output is verified.
SAMPLEOUTPUT:
PythonProgramExecutedOutput:
****************************************************************************************
Program13

CREATING A PYTHON PROGRAM TO INTEGRATE


MYSQLWITHPYTHON(INSERTINGRECORDSAND
DISPLAYING RECORDS)

AIM: To write a Python Program to integrate MYSQL with


Pythonby insertingrecordstoEmp table and display the
records.

SOURCECODE:

Result:Thus,theabovePythonprogramisexecutedsuccessfullyand the
output is verified.
SAMPLEOUTPUT:
PythonExecutedProgramOutput:

SQLOUTPUT:
Program14
CREATINGAPYTHONPROGRAMTOINTEGRATEMYSQL
WITH PYTHON(SEARCHING AND DISPLAYING
RECORDS)
AIM: To write a Python Program to integrate MYSQL with Python
to search an Employee using EMPID and display the record if
present in already existing table EMP, if not display the
appropriate message.

SOURCECODE:

Result:Thus,theabovePythonprogramisexecutedsuccessfullyand the
output is verified.
SAMPLEOUTPUT:
PythonExecutedProgram

Output:

RUN-1:

Run–2:

SQL

OUTPUT:OUTPUT -1:

OUTPUT-2:
Program15

CREATINGAPYTHONPROGRAMTOINTEGRATE MYSQL
WITH PYTHON(UPDATING RECORDS)
AIM:
To write a Python Program to integrate MYSQL with Python
to search an Employee using EMPID and update the Salary of
an employee if present in already existingtable EMP, if not
displaythe appropriatemessage.
SOURCECODE:

Result:Thus,theabovePythonprogramisexecutedsuccessfullyand the
output is verified.
SAMPLEOUTPUT:
PythonExecutedProgram

Output:

RUN-1:

Run-2:

SQLOUTPUT:
SQLCOMMANDSEXERCISE-1
Program
16

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Roll Name Gender Age Dept DOA Fees


no
1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytoCreatea newdatabaseinthename of"STUDENTS"

Sol:MySQL>CREATEDATABASESTUDENTS;

(b) Write a Queryto Openthedatabase"STUDENTS"

Sol:MySQL>USESTUDENTS;

(c) WriteaQuerytocreatetheabovetablecalled:Info

Sol:

MySQL>CREATETABLESTU(RollnointPrimarykey,Namevarchar(10),Gendervarchar
(3),Ageint,Deptvarchar(15),DOAdate,Feesint);

(d) WriteaQuerytolistalltheexistingdatabase names.


Sol:
mysql>SHOWDATABASES;
Output:
(e) WriteaQuerytoListallthetablesthatexistsin thecurrentdatabase.
Sol:
mysql>SHOWTABLES;
Output:

(f) WriteaQuerytoinsertalltherowsofabovetableintoInfotable.
Sol:
INSERTINTOSTUVALUES(1,'Arun','M',24,'COMPUTER','1997-01-10',120);

INSERT INTO STU VALUES (2,'Ankit','M', 21,'HISTORY','1998-03-24', 200);

INSERT INTO STU VALUES (3,'Anu','F', 20,'HINDI','1996-12-12', 300);

INSERT INTO STU VALUES (4,'Bala','M', 19, NULL,'1999-07-01', 400);

INSERT INTO STU VALUES (5,'Charan','M', 18,'HINDI','1997-06-27', 250);

INSERT INTO STU VALUES (6,'Deepa','F', 19,'HISTORY','1997-06-27', 300);

INSERTINTO STUVALUES (7,'Dinesh','M', 22,'COMPUTER','1997-02-25', 210); INSERT

INTO STU VALUES (8,'Usha','F', 23, NULL,'1997-07-31', 200);

(g) WriteaQuerytodisplayallthedetailsoftheEmployeesfromtheabovetable'STU'.

Sol:

mysql>SELECT*FROMSTU;

Output:

(h) WriteaquerytoRollno,NameandDepartment ofthestudentsfromSTU


[Link]:
mysql>SELECTROLLNO,NAME,DEPTFROMSTU;
SQLCOMMANDSEXERCISE–2
Program17

AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Roll Name Gender Age Dept DOA Fees


no
1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytoselectdistinctDepartmentfromSTUtable.
Sol:
mysql>SELECTDISTICT(DEPT)FROMSTU;

Output:

(b) ToshowallinformationaboutstudentsofHistorydepartment.
Sol:

mysql>SELECT* FROMSTUWHEREDEPT='HISTORY';

Output:

(c) Writea QuerytolistnameoffemalestudentsinHindi Department.


Sol:

mysql>SELECTNAMEFROMSTUWHEREDEPT='HINDI'ANDGENDER='F';

Output:
(d) WriteaQuerytolistnameofthestudents whoseagesarebetween18to20.
Sol:

mysql>SELECTNAMEFROMSTUWHEREAGEBETWEEN18AND20;

Output:

(e) WriteaQuerytodisplaythenameofthestudentswhosenameisstartingwith'A'.
Sol:

mysql>SELECTNAMEFROM STUWHERENAMELIKE'A%';

Output:

(f) Write aquerytolistthenames of thosestudentswhosenamehavesecondalphabet'n'intheir


names.
Sol:

mysql>SELECTNAMEFROMSTUWHERENAMELIKE'_N%';

********************************************************************************************************
SQLCOMMANDSEXERCISE-3
Program18
AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:

Roll Name Gender Age Dept DOA Fees


no
1 Arun M 24 COMPUTER 1997-01-10 120
2 Ankit M 21 HISTORY 1998-03-24 200
3 Anu F 20 HINDI 1996-12-12 300
4 Bala M 19 NULL 1999-07-01 400
5 Charan M 18 HINDI 1997-09-05 250
6 Deepa F 19 HISTORY 1997-06-27 300
7 Dinesh M 22 COMPUTER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(a) WriteaQuerytodelete thedetailsofRollnumberis8.


Sol:

mysql>DELETEFROMSTUWHEREROLLNO=8;

Output(AfterDeletion):

(b) Write a Query to change the fess ofStudentto 170 whose Roll numberis 1, if theexisting fess is
less than 130.
Sol:

mysql>UPDATE STUSETFEES=170 WHEREROLLNO=1ANDFEES<130;

Output(After Update):
(c) Writea QuerytoaddanewcolumnAreaof typevarcharintable STU.

Sol:
mysql>ALTERTABLESTUADDAREAVARCHAR(20);

Output:

(d) Write aQuerytoDisplayNameof all studentswhoseAreaContains NULL.

Sol:
mysql>SELECTNAMEFROMSTUWHEREAREAISNULL;

Output:

(e) WriteaQueryto deleteAreaColumnfromthetableSTU.

Sol:
mysql>ALTERTABLESTU DROP AREA;

Output:

(f) WriteaQuerytodeletetablefromDatabase.

Sol:
mysql>DROPTABLESTU;

Output:

*******************************************************************************************
SQLCOMMANDSEXERCISE-4
Program19
AIM:
TowriteQueriesforthefollowingQuestionsbasedonthegiventable:
TABLE:STOCK
Pno Pname Dcode Qty UnitPrice StockDate
5005 Ballpointpen 102 100 10 2021-03-31
5003 Gelpenpremium 102 150 15 2021-01-01
5002 Pencil 101 125 4 2021-02-18
5006 Scale 101 200 6 2020-01-01
5001 Eraser 102 210 3 2020-03-19
5004 Sharpner 102 60 5 2020-12-09
5009 Gelpenclassic 103 160 8 2022-01-19

TABLE:DEALERS
Dcode Dname
101 SakthiStationeries
103 ClassicStationeries
102 IndianBookHouse

(a) TodisplaythetotalUnitpriceofalltheproductswhoseDcode as 102.

Sol:
mysql> SELECT SUM(UNITPRICE) FROM STOCK GROUP BY DCODE HAVING
DCODE=102;

Output:

(b) Todisplaydetailsofall productsinthestocktable indescendingorderof Stockdate.

Sol:

mysql>SELECT*FROMSTOCKORDERBYSTOCKDATEDESC;

Output:
(c) To display maximumunitpriceof productsfor each dealer individually asper dcode from
the table Stock.

Sol:

mysql>SELECTDCODE,MAX(UNITPRICE)FROMSTOCKGROUPBYDCODE;

Output:

(d) TodisplaythePnameandDnamefrom tablestockanddealers.

Sol:
mysql>SELECTPNAME,DNAMEFROMSTOCKS,[Link]=[Link];

Output:

*************************************************************************************************

You might also like