Acknowledgement
I would like to express my sincere gratitude to all
those who helped me complete this project
successfully.
First and foremost, I would like to thank my
subject teacher, Mr. Dev Ranjan Biswas, for their
constant support, valuable guidance and
encouragement throughout the process.
I would also like to extend my thanks to our school
principal Mrs. Chitra Sharma, for providing all the
necessary facilities required for this project.
Finally, I would like to thank my family who
motivated me and boosted my morale when I was
stressed.
Certificate
This is to certify that Naman Agarwal, student of
class XII, Confluence World School has
completed the Practical File during the academic
year 2024-2025 based on the syllabus. She has
completed the practical work independently and
has shown utmost sincerity in completion of this
file. This practical file fully implements all the
topics and concepts learnt in Python and MySql
covered as per the C.B.S.E. syllabus of computer
science. I certify that this practical file is up to my
expectations and as per the guidelines issued by
C.B.S.E.
Teacher’s Signature Principal’s Examiner’s
PGT Computer Science Signature Signature
[Link] Name of the Exercise
Python Programs
1. Creating a menu driven program to perform arithmetic operations.
2. Creating a python program to display Fibonacci series
3. Creating a menu driven program to find factorial and sum of list of numbers 7
using function.
4. Creating a python program to implement returning value(s) from function. 9
5. Creating a python program to implement mathematical functions. 1
0
6. Creating a python program to generate random number between 1 to 6 1
1
7. Creating a python program to read a text file line by line and display each 1
word separated by '#'. 2
8. Creating a python program to read a text file and display the number of 1
3
vowels/consonants/lower case/ upper case characters.
9. Creating python program to display short words from a text file 1
5
10. Creating a python program to copy particular lines of a text file into another 1
text file. 6
11. Creating a python program to create and search records in binary file. 1
7
12. Creating a python program to create and update/modify records in binary 1
file. 9
13. Creating a python program to create and search employee’s record in csv file. 2
1
14. Creating a python program to implement stack operations (List). 2
3
15. Creating a python program to implement stack operations (Dictionary). 2
6
Python – SQL connectivity programs
16. Creating a python program to integrate MYSQL with Python (Creating 2
database and table) 8
17. Creating a python program to integrate MYSQL with Python (Inserting 3
records and displaying records) 0
18. Creating a python program to integrate MYSQL with Python (Searching and 3
displaying records) 2
19. Creating a python program to integrate MYSQL with Python (Updating 3
records) 3
SQL Queries
20. SQL COMMANDS EXERCISE – 1 3
5
21. SQL COMMANDS EXERCISE – 2 3
6
22. SQL COMMANDS EXERCISE – 3 3
8
23. SQL COMMANDS EXERCISE – 4 4
0
24. SQL COMMANDS EXERCISE – 5 4
2
Experiment No. 1
Aim: Creating a menu driven program to perform arithmetic
operations.
Source code:
Output-
Experiment No.2
Aim: Creating a python program to display Fibonacci series.
Source code:
Output:
Experiment No.3
Aim: Creating a menu driven program to find factorial and sum of
list of numbers using function.
Source code:
Output:
Experiment No.4
Aim: Creating a python program to implement returning value(s)
from function.
Source code:
Output:
Experiment No.5
Aim: Creating a python program to implement mathematical
functions.
Source code:
Output:
Experiment No.6
Aim: Creating a python program to generate random number 1 to 6.
Source code:
Output:
Experiment No.7
Aim: Creating a python program to read a text file line by line and
display each word separated by ‘#’.
Source code:
Output:
[Link]:
Experiment No.8
Aim: Creating a python program to read a text file and display the
number of Vowels/Consonants/Lower case/Upper case characters.
Source code:
Output:
[Link]:
Experiment No.9
Aim: Creating a python program to display short words from a text
file.
Source code:
Output:
[Link]:
Python Executed Program Output:
Experiment No.10
Aim: Creating a python program to copy particular lines of a text file
into another text file.
Source code:
Output:
[Link]:
Python Executed Program Output:
[Link]:
Experiment No.11
Aim: Creating a python program to create and search records
in binary file.
Source code:
Output:
Experiment No.12
Aim: Creating a python program to create and update/modify
records in binary file.
Source code:
Output:
Experiment No.13
Aim: Creating a python program to create and search employee’s
record in a CSV file.
Source code:
Output:
Experiment No.14
Aim: Creating a python program to implement stack operations
(List).
Source code:
Output:
Experiment No.15
Aim: Creating a python program to implement stack operations
(Dictionary).
Source code:
Output:
Experiment No.16
Aim: Creating a python program to integrate MYSQL with
python (Creating databases and table).
Source Code:
Output:
Experiment No.17
Aim: Creating a python program to integrate MYSQL with
python (Inserting records and displaying records).
Source Code:
Output:
Experiment No.18
Aim: Creating a python program to integrate MYSQL with
python (Searching and displaying records).
Source Code:
Output:
Experiment No.19
Aim: Creating a python program to integrate MYSQL with
python (Updating records).
Source Code:
Output:
Experiment No.20
Aim: To write Queries for the following Questions based on the
given table:
Roll No. Name Gender Age Dept DOA Fees
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) Write a Query to Create a new database in the name of "STUDENTS".
CREATE DATABASE STUDENTS;
(b) Write a Query to Open the database "STUDENTS".
USE STUDENTS;
(c) Write a Query to create the above table called: "STU"
CREATE TABLE STU
(ROLLNO INT PRIMARY KEY,
NAME VARCHAR(10),
GENDER VARCHAR(3),
AGE INT,DEPT VARCHAR(15),
DOA DATE,FEES INT);
(d) Write a Query to list all the existing database names.
SHOW DATABASES;
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
Output:
Experiment No.21
Aim: To write Queries for the following Questions based on the
given table:
(a) Write a Query to insert all the rows of above table into Info table.
INSERT INTO STU VALUES (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);
INSERT INTO STU VALUES (7,'Dinesh','M', 22,'COMPUTER','1997-02-25', 210);
INSERT INTO STU VALUES (8,'Usha','F', 23, NULL,'1997-07-31', 200);
(b) Write a Query to display all the details of the Employees from the
above table 'STU'.
SELECT * FROM STU;
Output:
(c) Write a query to Rollno, Name and Department of the students from STU
table.
SELECT ROLLNO, NAME, DEPT FROM STU;
Output:
(d) Write a Query to select distinct Department from STU table.
SELECT DISTICT(DEPT) FROM STU;
Output:
(e) To show all information about students of History department.
SELECT * FROM STU WHERE DEPT='HISTORY’;
Output:
Experiment No.22
Aim: To write Queries for the following Questions based on the
given table
Rollno Name Gender Age Dept DOA Fees
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) Write a Query to list name of female students in Hindi Department.
SELECT NAME FROM STU WHERE DEPT='HINDI' AND
GENDER='F';
Output:
(b) Write a Query to list name of the students whose ages are between 18 to
20.
SELECT NAME FROM STU WHERE AGE BETWEEN 18 AND 20;
Output:
(c) Write a Query to display the name of the students whose name is starting
with 'A'.
SELECT NAME FROM STU WHERE NAME LIKE 'A%';
Output:
Experiment No.23
Aim: To write Queries for the following Questions based on the
given table
Rollno Name Gender Age Dept DOA Fees
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) Write a Query to delete the details of Roll number is 8.
DELETE FROM STU WHERE ROLLNO=8;
Output (After Deletion):
(b) Write a Query to change the fess of Student to 170 whose Roll number is
1, if the existing fess is less than 130.
UPDATE STU SET FEES=170 WHERE ROLLNO=1 AND FEES<130;
Output (After Update):
(c) Write a Query to add a new column Area of type varchar in table STU.
ALTER TABLE STU ADD AREA VARCHAR(20);
Output:
(d) Write a Query to Display Name of all students whose Area Contains NULL.
SELECT NAME FROM STU WHERE AREA IS NULL;
Output:
(e) Write a Query to delete Area Column from the table STU.
ALTER TABLE STU DROP AREA;
Output:
(f) Write a Query to delete table from Database.
DROP TABLE STU;
Output:
Experiment No.24
Aim: To write Queries for the following Questions based on the
given table
TABLE: UNIFORM
Ucode Uname Ucolor StockDate
1 Shirt White 2021-03-31
2 Pant Black 2020-01-01
3 Skirt Grey 2021-02-18
4 Tie Blue 2019-01-01
5 Socks Blue 2019-03-19
6 Belt Black 2017-12-09
TABLE: COST
Ucode Size Price Company
1 M 500 Raymond
1 L 580 Mattex
2 XL 620 Mattex
2 M 810 Yasin
2 L 940 Raymond
3 M 770 Yasin
3 L 830 Galin
4 S 150 Mattex
(a) To Display the average price of all the Uniform of Raymond
Company from table COST.
SELECT AVG(PRICE) FROM COST WHERE COMPANY='RAYMOND';
Output:
(b) To display details of all the Uniform in the Uniform table in descending
order of Stock date.
SELECT * FROM UNIFORM ORDER BY STOCKDATE DESC;
Output:
(c) To Display max price and min price of each company.
SELECT COMPANY,MAX(PRICE),MIN(PRICE) FROM COST GROUP
BY COMPANY;
Output:
(d) To display the company where the number of uniforms size is more than 2.
SELECT COMPANY, COUNT(*) FROM COST GROUP BY
COMPANY HAVING COUNT(*)>2;
Output:
(e) To display the Ucode, Uname, Ucolor, Size and Company of tables uniform
and cost.
SELECT [Link],UNAME,UCOLOR,SIZE,COMPANY FROM
UNIFORM U,COST C WHERE [Link]=[Link];
Output: