Page 337 - C++
P. 337
4. (a) Write a statement in Python to open a text file STORY.TXT so that
new contents can be added at the end of it. 1
(b) Write a method in Python to read lines from a text file INDIA.TXT,
to find and display the occurrence of the word ‘‘India’’. 2
For example :
If the content of the file is
‘‘India is the fastest growing economy.
India is looking for more investments around the globe.
The whole world is looking at India as a great market.
Most of the Indians can foresee the heights that India is
capable of reaching.’’
The output should be 4.
(c) Considering the following definition of class MULTIPLEX, write a
method in Python to search and display all the contents in a pickled
file CINEMA.DAT, where MTYPE is matching with the value
‘Comedy’. 3
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
91 18