Set 3 - Bin Update
Set 3 - Bin Update
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’.
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.