B04C-2016D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2016-B04C #PYTHON#6498    siteicon   siteicon  

Problem Statement - B04C-2016D

Consider the following definition of class Staff, write a method in python to search and display the content in a pickled file staff.dat, where Staffcode is matching with ‘S0105’.

class Staff:
    def __init__(self,S,SNM):
        self.Staffcode=S
        self.Name=SNM
    def Show(self):
        print(self.Staffcode," ",
        self.Name)

Solution

TC++ #6498

def search():
    f = open(“staff.dat”, ‘rb’)
    try:
        while True:
            e = pickle.load(f)
            if e.Staffcode == ‘S0105’:
                e.Show()
    except EOFError:
        pass
    f.close(


Share

CSKC| Created: 12-Jan-2019 | Updated: 12-Jan-2019|CBSE12D-2016









Back