Sri Ram Dayal Khemka Vivekananda Vidyalaya Junior College: Half Yearly Examination 2024 - 2025
Sri Ram Dayal Khemka Vivekananda Vidyalaya Junior College: Half Yearly Examination 2024 - 2025
PYTHON PROGRAMS
1. Write a program in Python to implement a stack using a list data structure. Each node
should have • Book no • Book name • Book price.
2. Write a Program to integrate SQL with Python by importing the MYSQL module to
insert record for the following table Employee
Ecode Ename Edesignation
3. Assume a csv file “shop.csv” containing records of different products.
Each record has the structure [pno, pname, price]. Write a python program to add
and display the records from the file using the following functions.
Addproduct( ) – to input details of furniture and store them to the file
Showproduct( ) – to read and display the records whose price is more than 100.
4. Assume a binary file “Furniture.dat” containing records of different furniture.
Each record has the structure [ fno, fname, price]. Write a python program to add
and display the records from the file using the following functions.
Addfurniture( ) – to input details of furniture and store them to the file
Showfurniture( ) – to read and display the records whose price is more than 5000.
5. Write a python program to write 3 lines into the file “story.txt”. Then read the file and
display the words containing “a”.
6. Write a python program to write 5 lines into the file “words.txt”. Then read the file and
display all the words which are longer than 5 characters.
7. Write a function patterns(n) to display the following pattern for n lines, as per the number
passed to the function. The number to be input in main( ) function.
Enter the number:5
5
55
555
5555
55555
8. Write a python connectivity code to fetch and display all the records of a student table.
9. Assume a csv file “bikes.csv” containing records of different bikes.
Each record has the structure [bid, bname, cost]. Write a python program to add
and display the records from the file using the following functions.
Addbikes( ) – to input details of furniture and store them to the file
searchbikes(bikeid) – to read and display the bike records whose bid is passed as
the parameter to the function.
10. Assume a binary file “car.dat” containing records of different cars.
Each record has the structure [ carno, brand, kms, cost]. Write a python program to add
and display the records from the file using the following functions.
addcardata( ) – to input details of car and store them to the file
carreport( ) – to read and display the records who have run more than 100000 kms.
Sri Ram Dayal Khemka Vivekananda Vidyalaya Junior College
Half Yearly Examination 2024 – 2025 - Class : XII
Subject: Computer Science Subject Code: 083
Date & Day : 26.11.2024 (Tuesday) Mark : 30
SQL QUERIES
1. Consider the following table employee Write SQL commands for the statements
1 to 3 and outputs for 4 & 5
Table: Employee
EMPID ENAME JOBTITLE SALARY BONUS AGE
1205 Anitha CEO 30000 5000 32
1211 Rahul Manager 20000 1500 27
1213 Manisha Analyst 15000 NULL 24
1214 Megha Salesman 22000 1200 25
1216 Mohit Analyst 15000 1500 32
1217 Ramesh Salesman 25000 NULL 28
1. Create the above table. Primary key is empid
2. Display employee name and salaries of those employees whose salary is greater
than 20000
3. Update the age of the employees by 2 whose jobtitle starts with “A”
4. SELECT COUNT(*) FROM employee;
5. SELECT SUM(BONUS) FROM employee WHERE AGE>25;
2. Consider the following table Doctor Write SQL commands for the statements
1 to 3 and outputs for 4 & 5
Table Name: Doctor
dno docname Age Department Charge Sex
111 Arun 62 Surgery 300 M
222 Aparna 22 ENT 250 F
333 Kannan 32 Surgery 250 M
444 Anand 25 Surgery 300 M
555 Sundari 30 ENT 450 F
777 Supriya 28 Cardiology 450 F
888 Raj Kumar 25 ENT 400 M
4. Consider the following table Books Write SQL commands for the statements
1 to 3 and outputs for 4 & 5 Table: books
Bid Bname Aname Publisher Price Type Qty
1001 The Tears William Hopkins First 750 Fiction 10
2002 Thunderbolts Anna Roberts First 700 Fiction 5
3003 My first C++ Brain and Brooke EPB 250 Text 10
4004 Brain works A.W.Rossaine TDH 325 Text 5
5001 Fast Cook Latha Kapoor EPB 350 Cookery 8