5. 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%
Answers
Answered by
1
Question:
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%.
Solution:
import pickle
def CountRec():
fobj=open("STUDENT.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[2] > 75:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num
LearnMore on brainly.in:
Write a function in Python POP(Arr), where Arr is a stack implemented by a
list of numbers. The function returns the value deleted from the stack.
https://brainly.in/question/27632437
Similar questions
History,
4 months ago
Math,
4 months ago
Computer Science,
9 months ago
Social Sciences,
9 months ago
Biology,
1 year ago