Q. Anant has been asked to display all the students who have scored less than 40 for Remedial Classes, Write a user-defined function to display all those students who have scored less than 40 from the binary file "Student.dat".


Answer =


Let us consider the content of the file to be like this --


Name, Marks

 

def dispalyless40(aut):
    f = open("Student.dat", "rb")
    try :
        while True:
            data = pickle.load(f)
            if data[1] < 40 :
                print( data)
    except EOFError:
        f.close()

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post