12TH PROGRAMS
12TH PROGRAMS
NO: 1
AIM:
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
1
SAMPLE OUTPUT:
RUN- 2
***************************************************************************************
2
EX.NO: 2
AIM:
To write a Python Program to display Fibonacci Series up to ‘n’ numbers.
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
3
SAMPLE OUTPUT:
RUN -1:
RUN -2 :
*****************************************************************************************
4
EX.NO: 3
AIM:
To write a menu driven Python Program to find Factorial and sum of list of numbers
using function.
SOURCE CODE:
5
Result:
Thus, the above Python program is executed successfully and the output is verified.
6
SAMPLE OUTPUT:
RUN – 2:
**************************************************************************************
7
EX.NO: 4
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 is executed successfully and the output is verified.
8
SAMPLE OUTPUT:
**************************************************************************************
9
EX.NO: 5
AIM:
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
10
SAMPLE OUTPUT:
Python Executed Output Program:
**************************************************************************************
11
EX.NO: 6
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 is executed successfully and the output is verified.
12
SAMPLE OUTPUT:
Story.txt:
***************************************************************************************
13
EX.NO: 7
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
14
SAMPLE OUTPUT:
Story.txt:
***************************************************************************************
15
EX.NO:8
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 is executed successfully and the output is verified.
16
SAMPLE OUTPUT:
New.txt:
*****************************************************************************************
17
EX.NO: 9
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 is executed successfully and the output is verified.
18
SAMPLE OUPUT:
*******************************************************************************************
19
EX.NO: 10
SOURCE CODE:
Result:
20
Thus, the above Python program is executed successfully and the output is verified.
21
SAMPLE OUTPUT:
**********************************************************************************
22
EX.NO: 11
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:
23
Thus, the above Python program is executed successfully and the output is verified.
24
SAMPLE OUTPUT:
PYTHON PROGRAM EXECUTED OUTPUT:
******************************************************************************
25
EX.NO: 12
26
Result:
Thus, the above Python program is executed successfully and the output is verified.
27
SAMPLE OUTPUT:
Python Program Executed Output:
28
****************************************************************************************
29
EX.NO: 13
AIM:
To write a Python Program to integrate MYSQL with Python by inserting records to
Emp table and display the records.
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
30
SAMPLE OUTPUT:
SQL OUTPUT:
31
EX.NO: 14
SOURCE CODE:
Result:
Thus, the above Python program is executed successfully and the output is verified.
32
SAMPLE OUTPUT:
RUN -1:
Run – 2:
SQL OUTPUT:
OUTPUT -1:
OUTPUT -2:
33
EX.NO: 15
Result:
Thus, the above Python program is executed successfully and the output is verified.
34
SAMPLE OUTPUT:
RUN -1:
Run -2:
SQL OUTPUT:
35
SQL COMMANDS EXERCISE - 1
Ex.No: 16
AIM:
To write Queries for the following Questions based on the given table:
Sol:
36
(e) Write a Query to List all the tables that exists in the current database.
Sol:
mysql> SHOW TABLES;
Output:
(f) 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);
(g) Write a Query to display all the details of the Employees from the above table 'STU'.
Sol:
Output:
(h) Write a query to Rollno, Name and Department of the students from STU table.
Sol:
mysql> SELECT ROLLNO,NAME,DEPT FROM STU;
37
Ex.No: 17
SQL COMMANDS EXERCISE – 2
AIM:
To write Queries for the following Questions based on the given table:
Output:
Output:
Output:
38
(d) 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:
(e) Write a Query to display the name of the students whose name is starting with 'A'.
Sol:
Output:
(f) Write a query to list the names of those students whose name have second alphabet 'n' in their
names.
Sol:
********************************************************************************************************
39
Ex.No: 18 SQL COMMANDS EXERCISE - 3
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):
40
(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:
*******************************************************************************************
41
Ex.No: 19 SQL COMMANDS EXERCISE - 4
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 Stationeries
103 Classic Stationeries
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 GROUP BY DCODE HAVING
DCODE=102;
Output:
(b) To display details of all products in the stock table in descending order of Stock date.
Sol:
Output:
42
43
(c) To display maximum unit price of products for each dealer individually as per dcode
from the table Stock.
Sol:
Output:
(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;
Output:
*************************************************************************************************
44