79707935

Date: 2025-07-20 10:33:29
Score: 0.5
Natty:
Report link
import pickle

def create():
    fo = open("binary.dat", "wb")
    count = int(input("Enter number of records: "))
    for i in range(count):
        roll = 1
        name = 'er'
        class = 12
        data = [roll, name, class]
        pickle.dump(data, fo)
    fo.close()

def check():
    fo = open("binary.dat","rb+")
    search = 1
    name = 'dtghtfh'
    try:
        while True:
            rpos = fo.tell()
            data = pickle.load(fo)
            if data[0] ==search:
                data[1] = name
                fo.seek(rpos)
                pickle.dump(data, fo)
                #fo.truncate()

    except EOFError:
        fo.close()

def readall():
    with open("binary.dat", "rb") as fo:
        try:
            while True:
                data = pickle.load(fo)
                print(data)
        except EOFError:
            pass

create()
readall()
check()
readall()
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Aravind Sree U