Class 12 Cs Practical Exercises 2023-2024 (Updated)
Class 12 Cs Practical Exercises 2023-2024 (Updated)
PRACTICAL PROGRAMS
FOR GRADE – XII
[2023-2024]
Prepared by:
Mr. Appan Raj D M.C.A., B.Ed.,
1 - PGT CS
TABLE OF CONTENTS
2
EX.NO: 1
DATE:
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
3
SAMPLE OUTPUT:
***************************************************************************************
4
EX.NO: 2
DATE:
CREATING A PYTHON PROGRAM TO DISPLAY FIBONACCI SERIES
AIM:
To write a Python Program to display Fibonacci Series up to ‘n’ numbers.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
5
SAMPLE OUTPUT:
Python Executed Program Output:
*****************************************************************************************
6
EX.NO: 3
DATE:
AIM:
To write a menu driven Python Program to find Factorial and sum of list of numbers
using function.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
7
SAMPLE OUTPUT:
************************************************************************************************
8
EX.NO: 4
DATE:
AIM:
To Write a Python program to define the function Check(no1,no2) that take two numbers and
Returns the number that has minimum ones digit.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
**********************************************************************************
9
EX.NO: 5
DATE:
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
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
10
SAMPLE OUTPUT:
Python Executed Program Output:
**************************************************************************************
11
EX.NO: 6
DATE:
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
12
SAMPLE OUTPUT:
Python Executed Output Program:
**************************************************************************************
13
EX.NO: 7
DATE:
AIM:
To write a Python Program to Read a text file "Story.txt" line by line and display
each word separated by '#'.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
Story.txt:
14
EX.NO: 8
DATE:
To write a Python Program to read a text file "Story.txt" and displays the number of
Vowels/ Consonants/ Lowercase / Uppercase/characters in the file.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
15
SAMPLE OUTPUT:
Story.txt:
***************************************************************************************
16
EX.NO: 9
DATE:
AIM:
To Write a method Disp() in Python, to read the lines from poem.txt and display those
words which are less than 5 characters.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
Poem.txt:
17
EX.NO: 10
DATE:
AIM:
To write a python program to read lines from a text file "Sample.txt" and copy those lines
into another file which are starting with an alphabet 'a' or 'A'.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
18
SAMPLE OUTPUT:
New.txt:
*****************************************************************************************
19
EX.NO: 11
DATE:
AIM:
To write a Python Program to Create a binary file with roll number and name.
Search for a given roll number and display the name, if not found display appropriate
message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
20
SAMPLE OUPUT:
*******************************************************************************************
21
EX.NO: 12
DATE:
To write a Python Program to Create a binary file with roll number, name, mark
and update/modify the mark for a given roll number.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
22
SAMPLE OUTPUT:
PYTHON PROGRAM EXECUTED OUTPUT:
**********************************************************************************
23
EX.NO: 13
DATE:
AIM:
To write a Python program Create a CSV file to store Empno, Name, Salary and search
any Empno and display Name, Salary and if not found display appropriate message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
24
SAMPLE OUTPUT:
PYTHON PROGRAM EXECUTED OUTPUT:
******************************************************************************
25
EX.NO: 14
DATE:
(i) To Push an object containing Doc_ID and Doc_name of doctors who specialize
in "ENT" to the stack.
(ii) (ii) To Pop the objects from the stack and display them.
(iii)
(iv) (iii) To display the elements of the stack (after performing PUSH or POP)
SOURCE CODE:
26
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
27
SAMPLE OUTPUT:
Python Program Executed Output:
28
****************************************************************************************
29
EX.NO: 15
DATE:
AIM:
To Write a program, with separate user-defined functions to perform the following
operations:
(i) Create a function Push(Stk,D) Where Stack is an empty list and D is Dictionary of Items.
from this Dictionary Push the keys (name of the student) into a stack, where
the corresponding value (marks) is greater than 70.
(ii) Create a Function Pop(Stk) , where Stk is a Stack implemented by a list of student names.
The function returns the value deleted from the stack.
(iii) To display the elements of the stack (after performing PUSH or POP).
Source Code:
30
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
*********************************************************************************
31
EX.NO: 16
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(CREATING DATABASE AND TABLE)
AIM:
To write a Python Program to integrate MYSQL with Python to create Database and Table
to store the details of employees.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
32
Sample Output:
*******************************************************************************************************
33
EX.NO: 17
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(INSERTING RECORDS AND DISPLAYING RECORDS)
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
34
SAMPLE OUTPUT:
***************************************************************************************************************************** *************************************************
35
EX.NO: 18
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL 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.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
36
EX.NO: 19
DATE:
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 existing table
EMP, if not display the appropriate message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
37
SAMPLE OUTPUT:
**************************************************************************************************************************************************
38
SQL PRACTICAL - 1
Ex.No: 20
DATE:
AIM:
To write Queries for the following Questions based on the given table:
Sol:
(e) Write a Query to List all the tables that exists in the current database.
Sol:
mysql> SHOW TABLES;
Output:
39
SQL PRACTICAL - 2
Ex.No: 21
DATE:
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.
Sol:
INSERT INTO STU VALUES (1,'Arun','M', 24,'COMPUTER','1997-01-10', 120);
(b) Write a Query to display all the details of the Employees from the above table 'STU'.
Sol:
40
(c) Write a query to Rollno, Name and Department of the students from STU table.
Sol:
mysql> SELECT ROLLNO,NAME,DEPT FROM STU;
Output:
Output:
********************************************************************************************
41
Ex.No: 22 SQL PRACTICAL - 3
DATE:
AIM:
To write Queries for the following Questions based on the given table:
Output:
(b) Write a Query to list name of the students whose ages are between 18 to 20.
Sol:
mysql> SELECT NAME FROM STU WHERE AGE BETWEEN 18 AND 20;
Output:
42
(c) Write a Query to display the name of the students whose name is starting with 'A'.
Sol:
Output:
(d) Write a query to list the names of those students whose name have second alphabet 'n' in their
names.
Sol:
********************************************************************************************************
43
Ex.No: 23 SQL PRACTICAL - 4
DATE:
AIM:
To write Queries for the following Questions based on the given table:
(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.
Sol:
Output(After Update):
44
(c) Write a Query to add a new column Area of type varchar in table STU.
Sol:
mysql> ALTER TABLE STU ADD AREA VARCHAR(20);
Output:
(d) Write a Query to Display Name of all students whose Area Contains NULL.
Sol:
mysql> SELECT NAME FROM STU WHERE AREA IS NULL;
Output:
(e) Write a Query to delete Area Column from the table STU.
Sol:
mysql> ALTER TABLE STU DROP AREA;
Output:
Sol:
mysql> DROP TABLE STU;
Output:
*******************************************************************************************
45
Ex.No: 24 SQL PRACTICAL - 4
DATE:
AIM:
To write Queries for the following Questions based on the given table:
TABLE: STOCK
Pno Pname Dcode Qty UnitPrice StockDate
5005 Ball point pen 102 100 10 2021-03-31
5003 Gel pen premium 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 Gel pen classic 103 160 8 2022-01-19
TABLE: DEALERS
Dcode Dname
101 Sakthi Stationaries
103 Classic Stationaries
102 Indian Book House
(a) To display the total Unit price of all the products whose Dcode as 102.
Sol:
mysql> SELECT SUM(UNITPRICE) FROM STOCK WHERE DCODE=102;
(b) To display details of all products in the stock table in descending order of Stock date.
Sol:
(c) To display maximum unit price of products for each dealer individually as per dcode
from the table Stock.
Sol:
(d) To display the Pname and Dname from table stock and dealers.
Sol:
mysql> SELECT PNAME,DNAME FROM STOCK S,DEALERS D WHERE S.DCODE=D.DCODE;
*************************************************************************************************
46