0% found this document useful (0 votes)
37 views43 pages

CLASS - 12 - English Project

Uploaded by

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

CLASS - 12 - English Project

Uploaded by

missangelqueen3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

COMPUTER

SCIENCE PRACTICAL
PROGRAMS
FOR GRADE –
XII [2023-
2024]

Prepared by:
Mr. Appan Raj D M.C.A., B.Ed., -
1
TABLE O F CONTENTS

S.No Name of the Exercise Page.No


Python Programs
1. Creating a menu driven program to perform arithmetic operations. 3
2. Creating a python program to display Fibonacci series 5
3. Creating a menu driven program to find factorial and s u m of list of numbers using 7
function.
4. Creating a python program to implement returning value(s) from function. 9
5. Creating a python program to implement mathematical functions. 10
6. Creating a python program to generate random number between 1 to 6 11
7. Creating a python program to read a text file line by line and display each word 12
separated by '#'.
8. Creating a python program to read a text file and display the number of 13
vowels/consonants/lower case/ upper case characters.
9. Creating python program to display short words from a text file 15
10. Creating a python program to copy particular lines of a text file into another text 16
file.
11. Creating a python program to create and search records in binary file. 17
12. Creating a python program to create and update/modify records in binary file. 19
13. Creating a python program to create and search employee’s record in csv file. 21
14. Creating a python program to implement stack operations (List). 23
15. Creating a python program to implement stack operations (Dictionary). 26
Python – S Q L connectivity programs
16. Creating a python program to integrate M YS Q L with Python (Creating database 28
and table)
17. Creating a python program to integrate M YS Q L with Python (Inserting records 30
and displaying records)
18. Creating a python program to integrate M YS Q L with Python (Searching and 32
displaying records)
19. Creating a python program to integrate M YS Q L with Python (Updating records) 33
S Q L Queries
20. S Q L C O M M A N D S E X E RC I S E – 1 35
21. S Q L C O M M A N D S E X E RC I S E – 2 36
22. S Q L C O M M A N D S E X E RC I S E – 3 38
23. S Q L C O M M A N D S E X E RC I S E – 4 40
24. S Q L C O M M A N D S E X E RC I S E – 5 42

2
EX.NO: 1
DATE:

CREATING A MENU DRIVEN PRO GR A M TO PERFORM ARITHMETIC


OPERATIONS
AIM:

To write a menu driven Python Program to perform Arithmetic operations (+,-


*,/)
based on the user’s choice.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

3
SAMPLE OUTPUT:

Python Program Executed Output:

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

4
EX.NO: 2
DATE:
CREATING A PYTHON PRO GR A M TO DISPLAY F

AIM:
To write a Python Program to display Fibonacci Serie

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

5
SAMPLE OUTPUT:
Python Executed Program Output:

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

6
EX.NO: 3

DATE:

CREATING A MENU DRIVEN PRO GR A M TO FIND FACTOR


NUMBERS USING FUNCTION

AIM:
To write a menu driven Python Program to find Factor
using function.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

7
SAMPLE OUTPUT:

Python Executed Program Output:

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

8
EX.NO: 4

DATE:

CREATING A PYTHON PRO GR A M TO IMPLEME


FROM FUNCTION

AIM:

To Write a Python program to define the function Check(no1,n


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:

CREATING A PYTHON PRO GR A M 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 fin d L o g of a N u m b e r ( i . e . Log 10 )
(iii
To find Quad of a Number
)
S O U R C E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:
Python Executed Program Output:

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

10
EX.NO: 6

DATE:

CREATING A PYTHON PRO GR A M TO GENERATE R A ND O M NUMBER


BETWEEN 1 TO 6
AIM:

To write a Python program to generate random number between 1 to 6 to simulate


the dice.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:

Python Executed Output Program:

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

11
EX.NO: 7
DATE:

CREATING A PYTHON PRO GR A M TO READ A TEXT F


DISPLAY EACH WO R D SEPARATED

AIM:

To write a Python Program to Read a text file "Story.txt" line b


word separated by '#'.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:
Story.txt:

12
EX.NO: 8

DATE:

CREATING A PYTHON PRO GR A M TO READ A TEXT F


NUMBER OF VOWELS/CONSONANTS/LOWER CASE/ U
AIM:

To write a Python Program to read a text file "Stor


of Vowels/ Consonants/ Lowercase / Uppercase/char

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

13
SAMPLE OUTPUT:
Story.txt:

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

14
EX.NO: 9
DATE:

CREATING PYTHON PRO GR A M TO DISPLAY SHORT W

AIM:
To Write a method Disp() in Python, to read the lines fro
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:

Python Executed Program Output:

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

15
EX.NO: 10

DATE:

CREATING A PYTHON PRO GR A M TO COPY PARTICULA


INTO AN ANOTHER TEXT FIL
AIM:

To write a python program to read lines from a text file "Sam


into another file which are starting with an alphabet 'a' or 'A'

S O U R C E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:
Python Executed Program output:
Sample.txt:

Python Executed Program Output:

New.txt:

******************************************************************
16
EX.NO: 11
DATE:

CREATING A PYTHON PRO GR A M TO CREATE AND


BINARY FILE

AIM:

To write a Python Program to Create a binary file


Search for a given roll number and display the name,
message.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

17
SAMPLE OUPUT:

PYTHON PRO GR A M EXECUTED OUTPUT:

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

18
EX.NO: 12
DATE:

CREATING A PYTHON PRO GR A M TO CREATE AND UPDA


BINARY FILE
AIM:

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


update/modify the mark for a given roll number.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

19
SAMPLE OUTPUT:
PYTHON PRO GR A M EXECUTED OUTPUT:

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

20
EX.NO: 13
DATE:

CREATING A PYTHON PRO GR A M TO CREATE AND SEAR


IN CSV FILE.

AIM:

To write a Python program Create a CSV file to store Empno, Name


and display Name, Salary and if not found display appropriate m

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

21
SAMPLE OUTPUT:

PYTHON PRO GR A M EXECUTED OUTPUT:

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

22
EX.NO: 14
DATE:

CREA
TING
A
PYTH
ON
PRO G
RAM
TODoc_name of doctors who specialize
(i)
To Push an object containing Doc_ID and
in "ENT" to the stack. IMPL
(ii) To Pop the objects from the stack and (ii)
display
EMEN them.
(iii) T
(iv) (iii) To display the elements of the stack (after
STACKperforming PUSH or POP)
OPER
S O U R C E CODE: ATION
S(LIST
)

AIM:
To
write a
Python
progra
m to
implem
ent
Stack
using a
list
data-
structur
e, to
perform

the
followi
ng
operati
ons:

23
Result:

Thus, the above Python program has been executed and the output is verified
successfully.

SAMPLE OUTPUT:
Python Program Executed Output:

24
**********************************************************************

25
EX.NO: 15
DATE:

CREATIN
GA
PYTHON
PRO GR A
M TO
IMPLEM
ENT
STACK
OPERATI
ONS(Dict
ionary)

AIM:
To Write a program, with separate user-defined functi
operations:
(i) To Create a function Push(Stk,D) Where Stack is an empty
from this Dictionary Push the keys (name o
where the corresponding value (marks) is greater than
(ii) To Create a Function Pop(Stk) , where Stk is a Stack impl
names. The function returns the items deleted from
(iii) To display the elements of the stack (after performing PUSH
Source Code:

26
Result:

Thus, the above Python program has been executed and the output is verified
successfully.

Sample Output:

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

27
EX.NO: 16
DATE:
CREATING A PYTHON PRO GR A M TO INTEGRATE MY
(CREATING DATABASE AND TABL
AIM:
To write a Python Program to integrate MYSQL with Python to
Table
to store the details of employees.

Source Code:

Result:

Thus, the above Python program has been executed a


successfully.

28
Sample Output:

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

29
EX.NO: 17
DATE:
CREATING A PYTHON PRO GR A M TO INTEGRATE MYSQL WITH PYTHON
(INSERTING RECORDS AND DISPLAYING RECORDS)

AIM:
To write a Python Program to integrate MYSQL with Python by inserting records to
Emp table and display the records.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed and


successfully.

30
SAMPLE OUTPUT:

Python Executed Program Output:

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

31
EX.NO: 18

DATE:
CREATING A PYTHON PRO GR A M 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.

S O U R C E CODE:

Result:

Thus, the above Python program has been executed a


successfully.

SAMPLE OUTPUT:

Python Executed Program Output:

32
EX.NO: 19
DATE:

CREATING A PYTHON PRO GR A M TO INTEGRATE 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 existing table
EMP, if not display the appropriate message.
S O U R C E CODE:

Result:

Thus, the above Python program has been executed and the output is verified
successfully.

33
SAMPLE OUTPUT:

Python Executed Program Output:

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

34
S Q L CO M M A ND S E X E R C I S E - 1
Ex.No: 20
DATE:

AIM:
To
writ
e
Que
ries
for
the
follo
wing
Que
stio
ns
bas
ed
on
the
give
n
tabl
e:
Rollno Name Gender Age Dept DOA Fees
1 Arun M 24 COMPU TER 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 COMPU TER 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".

C R E AT E DATABASE STUDENTS;

(b) Write a Query to Open the database "STUDENTS".

U S E STUDENTS;

(c) Write a Query to create the above table called: "STU"

C R E AT E TABLE STU(ROLLNO INT PRIMARY K EY,NA M E VARCHAR(10),


G E N D E R VARCHAR(3), AG E INT,DEPT VARCHAR(15),
DOA DAT E , F E E S INT);

(d) Write a Query to list all the existing database names.

SHOW DATABASES;
S Q L CO M M A ND S E X E R C I S E - 2
Ex.No: 21
DATE:

AIM:
To
writ
e
Que
ries
for
the
follo
wing
Que
stio
ns
bas
ed
on
the
give
n
tabl
e:
Rollno Name Gender Age Dept DOA Fees
1 Arun M 24 COMPU TER 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 COMPU TER 1997-02-25 210
8 Usha F 23 NULL 1997-07-31 200

(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'.

S E L E C T * F RO M STU;

Output:
(c) Write a query to Rollno, Name and Department of the students from STU table.

S E L E C T ROLLNO,NAME,DEPT F RO M STU;

Output:

(d) Write a Query to select distinct Department from STU table.

S E L E C T DISTICT(DEPT) F RO M STU;

Output:

(e) To show all information about students of History department.

S E L E C T * F RO M STU WHERE DEPT='HISTORY';

Output:

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

37
Ex.No: 22 S Q L CO M M A ND S E X E R C I S E

- 3 DATE:

AIM:
To write Queries for the following Questions based on the
given table:
Rollno Name Gender Age Dept DOA Fees
1 Arun M 24 COMPU TER 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 COMPU TER 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.

S E L E C T NAME F RO M 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.

S E L E C T NAME F RO M STU WHERE AG E BETWEEN 18 AND 20;

Output:

38
(c) Write a Query to display the name of the students whose name is starting with 'A'.

S E L E C T NAME F RO M STU WHERE NAME L IK E 'A%';

Output:

(d) Write a query to list the names of those students whose nam
names.

S E L E C T NAME F RO M STU WHERE NAME LIKE '_N%';

Output:

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

39
Ex.No: 23 S Q L CO M M A ND S E X E R C I S E

DATE:

AIM:
To write Queries for the following Questions based on the given table:

Rollno Name Gender Age Dept DOA Fees


1 Arun M 24 COMPU TER 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 COMPU TER 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.

D E L E T E F RO M 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 S E T FEES=170 WHERE ROLLNO=1 AND FEES<130;

Output(After Update):

40
(c) Write a Query to add a new column Area of type varchar in table STU.

ALT ER TABLE STU ADD AREA VARCHAR(20);

Output:

(d) Write a Query to Display Name of all students whose Area Contains NULL.

S E L E C T NAME F RO M STU WHERE AREA IS NULL;

Output:

(e) Write a Query to delete Area Column from the table STU.

ALT ER TABLE STU DROP AREA;

Output:

(f) Write a Query to delete table from Database.

DROP TABLE STU;

Output:
**************************************************************

41
Ex.No: 24 S Q L CO M M A ND S E X E R C I S E -
DATE:

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: CO ST

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

S E L E C T AVG(PRICE) F RO M CO S T WHERE COMPANY='RA

Output:

(b) To display details of all the Uniform in the Uniform table in descending order of Stock date.

S E L E C T * F RO M UNIFORM O R D E R BY STO C K DAT E D E S C ;

Output:

42
(c) To Display max price and min price of each company.

S E L E C T COMPANY,MAX(PRICE),MIN(PRICE) F RO M C O S T GROUP BY COMPANY;

Output:

(d) To display the company where the number of uniforms size is more than 2.

S E L E C T COMPANY, COUNT(*) F RO M C O S T GROUP BY COMPANY HAVING COUNT(*)>2;

Output:

(e) To display the Ucode, Uname, Ucolor, Size and Company of t

S E L E C T U.UCODE,UNAME,UCOLOR,SIZE,COMPANY F RO M UNIFORM U,CO ST C WHERE


U.UCODE=C.UCODE;

Output:

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

43

You might also like