Computer Science, asked by shreyansh007singh, 5 months ago

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 duragpalsingh
2

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

Answered by nehaprasanth1889
0

Answer:

def count():

   import pickle

   count=0

   f=open("attendance.dat","rb")

   while True:

       try:

           x=pickle.load(f)

           p=x[2]/x[3]*100

           if p<75:

               print(x)

               count+=1

       except:

           break

   print(count)

   f.close()

Explanation:

hope this helps!

Similar questions