मराठी

A Binary file, CINEMA.DAT has the following structure: {MNO:[MNAME, MTYPE]} Where MNO - Movie Number MNAME - Movie Name MTYPE is Movie Type Write a user defined function, findType(mtype)

Advertisements

प्रश्न

A Binary file, CINEMA.DAT has the following structure:

{MNO:[MNAME, MTYPE]}

Where

  • MNO - Movie Number
  • MNAME - Movie Name
  • MTYPE is Movie Type

Write a user defined function, findType(mtype), that accepts mtype as parameter and displays all the records from the binary file CINEMA.DAT, that have the value of Movie Type as mtype.

टीपा लिहा
Advertisements

उत्तर

def Searchtype (mtype) :
            fObj = open("CINEMA.DAT", "rb")
            try:
                   while True:
                           data = pickle.load(fObj)
                           if data[2] == mtype:
                              print ("Movie number:",data[0])
                              print ("Movie Name:",data[1])
                              print ("Movie Type:",data[2])
except EOFError:
          fObj.close ()
shaalaa.com
The Pickle Module in Python
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2023-2024 (March) Board Sample Paper
Advertisements
Share
Notifications



      Forgot password?
Use app×