0% found this document useful (0 votes)
21 views5 pages

Set 3 - Bin Update

The document outlines the practical examination for Computer Science, including tasks such as writing a Python program to manage doctor records in a binary file and SQL queries related to a chips table. It specifies the structure of the doctor records and provides example functions for inserting, reading, and updating records. Additionally, it includes SQL tasks for displaying and deleting chip records based on specified criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

Set 3 - Bin Update

The document outlines the practical examination for Computer Science, including tasks such as writing a Python program to manage doctor records in a binary file and SQL queries related to a chips table. It specifies the structure of the doctor records and provides example functions for inserting, reading, and updating records. Additionally, it includes SQL tasks for displaying and deleting chip records based on specified criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

All India Senior School Certificate Examination 2023-24

Practical Examination - Computer Science (083)


SET 3
Time: 3:00 Hours Max. Marks: 30
Q 1. a) Write a menu-driven program in python to implement following on binary file of the given
structure: 8
[Doctor_Id, Doctor_Name, Hospital_Id,Joining_Date,Speciality,Salary]
1. Write a record to the file
2. Read all the records to the file
3. Update Record
4. Exit
b) Consider the table given below and write the sql queries based on the table data 4
Table Name : Chips

a. Display the flavour and its total price of the Tomato flavor chips : Total price=price*quantity
b. Display the brandname and flavour of the chips with price in the range of 10 to 15.
c. To display brandwise total flavours the supply.
d. Delete the chips who’s brandname contains the letter ‘a’.

Q2. Practical Report File 7


Q3. Project 8
Q4. Viva Voce 3
Solution:
import pickle
def insertRec():
doctor_id = int(input('Enter doctor id:'))
doctor_name = input('Enter Name:')
hospital_id = int(input('Enter hosptial id:'))
joining_date=input("Enter date:")
speciality=input("Enter speciality:")
salary=float(input("Enter Salary:"))
rec=[doctor_id,doctor_name,hospital_id,joining_date,speciality,salary]
f=open('hospital.dat','ab')
pickle.dump(rec,f)
f.close()

def readRec():
f=open('hospital.dat','rb')
while True:
try:
rec=pickle.load(f)
print(rec)
except EOFError:
break
f.close()

def updaterec():
f=open('hospital.dat','rb')
r1=[]
while True:
try:
r=pickle.load(f)
r1.append(r)
except EOFError:
break
f.close()
print(r1)
d_id=int(input("Enter doctor id to update:"))
found=0
doctor_name=input('Enter new Name:')
hospital_id=int(input('Enter new hosptial id:'))
joining_date=input("Enter new date:")
speciality=input("Enter new speciality:")
salary=float(input("Enter new Salary:"))
for i in range (len(r1)):
if r1[i][0]==d_id:
found=1
r1[i][1]=doctor_name
r1[i][2]=hospital_id
r1[i][3]=joining_date
r1[i][4]=speciality
r1[i][5]=salary
f=open('hospital.dat','wb')
for x in r1:
pickle.dump(x,f)
f.close()
if found==0:
print("Record not Found...")

def menu():
while True:
print('''
1. Write a record to the file
2. Read all the records to the file
3. Update Record
4. Exit
''')
ch = int(input('Enter you choice:'))
if ch == 1:
insertRec()
elif ch == 2:
readRec()
elif ch == 3:
updaterec()
elif ch == 4:
print("Thank you, visit again!")
break
menu()

SQL

a. Display the flavour and its total price of the Tomato flavor chips : Total
price=price*quantity

b. Display the brandname and flavour of the chips with price in the range of 10 to 15.
c. To display brandwisw total flavours the supply.

d. Delete the chips who’s brandname contains the letter ‘a’.

You might also like