In this article, I will discuss CS Class 12 Board Practical Paper 1 Solution 2024. The board has released the guidelines for conducting practical exams in January 2024. Let us begin!
Topics Covered
CS Class 12 Board Practical Paper 1 Solution 2024
The first question is the Python program. I have taken this from file handling. In this Let us begin with question 1:
Question 1 – Python Program
Q – 1 a) Write a menu drive program to perform the following operations into a binary file shoes.dat 8
- Add Record
- Display records
- Search record
- Exit
The structure of file content is: [s_id, name, brand, type, price]
Solution Question 1
import pickle
l=[]
found=0
def add_rec():
f=open("shoes.dat","ab")
s_id=int(input("Enter Shoes ID:"))
nm=input("Enter Name:")
br=input("Enter Brand:")
ty=input("Enter Type:")
pr=int(input("Enter Price:"))
l=[s_id,nm,br,ty,pr]
pickle.dump(l,f)
print("Record Added....")
f.close()
def dis_rec():
f=open("shoes.dat","rb")
while True:
try:
l=pickle.load(f)
print(l)
except EOFError:
f.close()
break
def search_record():
f=open("shoes.dat","rb")
s_id=int(input("Enter Shoe ID:"))
while True:
try:
l=pickle.load(f)
if l[0]==s_id:
found=1
print("Record Found...",l)
else:
found=0
except EOFError:
f.close()
break
if found==0:
print("Record Not Found...")
while True:
print('''
1. Add Record
2. Display Record
3. Search Record
4. Exit
''')
ch=int(input("Enter your choice:"))
if ch==1:
add_rec()
elif ch==2:
dis_rec()
elif ch==3:
search_record()
elif ch==4:
break
else:
print("Invalid Choice")
b) Observe the following tables of customer and order and write queries given below 4
Table – Customer
CustomerID | CustomerName | City | MobileNo |
C111 | Abhishek | Ahmedabad | 9999999999 |
C132 | Bhavik | Anand | 7799779977 |
C135 | Chandani | Baroda | 8856895485 |
C145 | Dhara | Ahmedabad | 7456879652 |
C121 | Divya | Anand | 9015123569 |
Table – Order
OrderID | OrderDate | OrderAmt | CustomerID |
O111 | 2022-04-15 | 1500 | C111 |
O112 | 2022-05-20 | 1800 | C121 |
O113 | 2022-05-31 | 1000 | C199 |
O131 | 2022-06-12 | 1400 | C135 |
(i) Display CustomerID, CustomerName and bill amount for customers belonging to Ahmedabad.
Ans.: select customerid, customername, orderamt from customer, order where customer.customerid = order.customerid and city=’ahmedabad’;
(ii) Display the order details in descending order of amount
Ans.: select * from order order by orderamt desc;
(iii) Display OrderId, Orderdate , customername and mobileno of customers whose name ends with ‘k’ and name contains letter ‘h’
Ans.: select orderid, orderdate, customername, mobileno from customer, order where customer.customerid = order.customerid and (customername like ‘%k’ or customername like ‘%h%’;
(iv) Display the sum of order amount for each city
Ans.: select city,sum(orderamt) from customer,order where customer.customerid = order.customerid group city;
Watch this video for more understanding: