B04C – Computer Sir Ki Class

Login


Lost your password?

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

Login
[lwa]



Exam Questions-CBSE12A-2018-B04C #PYTHON#6144    siteicon   siteicon  

Problem Statement - B04C

Considering the following definition of class MULTIPLEX, write a method in python to search and display all the content in a pickled file CINEMA.DAT, where MTYPE is matching with the value ‘Comedy’.

class MULTIPLEX:
    def __init__(self,mno,mname,mtype):
        self.MNO = mno
        self.MNAME = mname
        self.MTYPE = mtype
    def Show(self):
        print self.MNO:"*",self.MNAME,"$",self.MTYPE

Solution

TC++ #6144

def Search():
    file=open('CINEMA.DAT','rb')
    try:
        while True:
            M=pickle.load(file)
            if M.MTYPE=="Comedy":
                M.Show()
    except EOFError:
       pass
       file.close()


Share

CSKC| Created: 9-Jan-2019 | Updated: 10-Jan-2019|CBSE12A-2018









Back