Page 237 - C++
P. 237

(d)  Write definition of a Method AFIND(CITIES) to display all the city names from a
                         list of CITIES, which are starting with alphabet A.                                2


                         For example :

                         If the list CITIES contains


                         ["AHMEDABAD","CHENNAI","NEW DELHI","AMRITSAR","AGRA"]

                         The following should get displayed

                         AHMEDABAD


                         AMRITSAR

                         AGRA


                   (e)   Evaluate the following Postfix notation of expression :                            2


                         2,3,*,24,2,6,+,/,–



             4.    (a)   Differentiate between file modes r+ and w+ with respect to Python.               1

                   (b)  Write a method in Phyton to read lines from a text file DIARY.TXT, and display

                         those lines, which are starting with an alphabet ‘P’.                            2

                   (c)   Considering  the  following  definition  of  class  COMPANY,  write  a  method  in

                         Python to search and display the content in a pickled file COMPANY.DAT, where

                         CompID is matching with the value ‘1005’.                                        3

                         class Company:

                             def_init_(self,CID,NAM):


                                 self.CompID          =  CID       # CompID Company ID

                                 self.CName           =  NAM       # CName Company Name


                                 self.Turnover  =  1000

                             def Display(self):

                                 print self.CompID,":",self.CName,":",self.Tunover


             91/1                                          12
   232   233   234   235   236   237   238   239   240   241   242