XII - CS - Practical Record
XII - CS - Practical Record
XII - CS - Practical Record
Program 1
To write a menu driven Python Program to perform Arithmetic operations (+,-*, /) based on the
user’s choice.
SOURCE CODE:
SAMPLE OUTPUT:
Run – 1:
RUN- 2
Program 2
SOURCE CODE:
Program Output:
RUN -1:
RUN -2 :
Program 3
To write a menu driven Python Program to find Factorial and sum of list of numbers using function.
SOURCE CODE:
Program Output:
RUN -1:
RUN – 2:
Program 4
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:
Program Output:
Program 5
To write a Python program to generate random number between 1 to 6 to simulate the dice.
SOURCE CODE:
Output :
Program 6
To write a Python Program to Read a text file "Story.txt" line by line and display each word
separated by '#'.
SOURCE CODE:
OUTPUT:
Story.txt:
Program 7
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:
OUTPUT:
Story.txt:
Program 8:
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:
Python Executed Program Output:
New.txt:
Program 9:
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 CO DE:
OUTPUT:
OUTPUT:
Program 11:
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:
OUTPUT:
Program 12:
SOURCE CODE:
OUTPUT:
SQL OUTPUT:
Program 14:
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:
OUTPUT:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(UPDATING RECORDS )
AIM:
.
SQL TABLE 1
Write queries for the following questions based on the given table:
Rollno Name Gender Age Dept DOA Fees
SQL Table 1
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;
(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:
(h) Write a query to Rollno, Name and Department of the students from STU table.
Sol:
mysql> SELECT ROLLNO,NAME,DEPT FROM STU;
SQL TABLE 2 :
Write queries for the following questions based on the given table:
(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;
(e) Write a Query to display the name of the students whose name is starting with 'A'.
Sol:
(f) Write a query to list the names of those students whose name have second alphabet 'n' in
their names.
Sol:
********************************************************************************************************
SQL Table 3 :
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:
Sol:
mysql> ALTER TABLE STU ADD AREA VARCHAR(20);
(d) Write a Query to Display Name of all students whose Area Contains NULL.
Sol:
mysql> SELECT NAME FROM STU WHERE AREA IS NULL;
(e) Write a Query to delete Area Column from the table STU.
Sol:
mysql> ALTER TABLE STU DROP AREA;
Sol:
mysql> DROP TABLE STU;
SQL TABLE - 4
Write Queries for the following questions based on the given table:
TABLE: STOCK
TABLE: DEALERS
Dcode Dname
Sol:
(c) To display maximum unit price of products for each dealer individually as per dcode
from the table Stock.
Sol:
Sol:
mysql> SELECT PNAME,DNAME FROM STOCK S,DEALERS D WHERE
S.DCODE=D.DCODE;
*************************************************************************************************