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 7
Answers
Answered by
0
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
Math,
3 months ago
English,
3 months ago
Computer Science,
8 months ago
Physics,
8 months ago
Math,
1 year ago
Business Studies,
1 year ago