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!

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

  1. Add Record
  2. Display records
  3. Search record
  4. 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

Table – Customer

CustomerIDCustomerNameCityMobileNo
C111AbhishekAhmedabad9999999999
C132BhavikAnand7799779977
C135ChandaniBaroda8856895485
C145DharaAhmedabad7456879652
C121DivyaAnand9015123569

Table – Order

OrderIDOrderDateOrderAmtCustomerID
O1112022-04-151500C111
O1122022-05-201800C121
O1132022-05-311000C199
O1312022-06-121400C135

(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:


Leave a Reply