Q. Given a binary file "STUDENT.DAT", containing records of the following type:
[S_Admno, S_Name, Percentage]
Where these three values are:
S_Admno - Admission Number of student (string)
S_Name - Name of student (string)
Percentage - Marks percentage of student (float)
Write a function in Python that would read contents of the file "STUDENT.DAT" and display the details of those students whose percentage is above 75.
Answer =
import pickle f = open("STUDENT.DAT ","rb") datalst = [ ] while True : try : data = pickle.load(f) datalst += [data] except EOFError : break f.close() for i in datalst : if i [2] > 75 : print(i)
Thank you
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )