A binary file “STORE.DAT” has structure ( ITEM_ID, ITEM_NAME, QTY,PRICE). Write a
function Display_ Rec() in python to display the details of items have quantity is more than 35 from
the file “STORE.DAT” and also print the total number of records
in the file.
Answers
Explanation:
A binary file “STUDENT.DAT” has structure (admission_number, Name, Percentage). Write a function countrec() in Python that would read contents of the file “STUDENT.DAT” and display the details of those students whose percentage is above 75. Also display number of students scoring above 75%.Read more on Sarthaks.com - https://www.sarthaks.com/969038/a-binary-file-student-dat-has-structure-admissionnumber-name-percentage
Answer:
import pickle
def Display_Rec() :
file=open("STORE.DAT",'rb')
count=0
while True:
try:
R=pickle.load(file)
print(R)
count+=1
if R[2]>35:
print("Item_id",R[0])
print("Item_name",R[1])
except:
break
print(count)
f.close()
Explanation: