Page 333 - C++
P. 333

(f)     What  possible  output(s)  are  expected  to  be  displayed  on  screen  at
                   the time of execution of the program from the following code ? Also
                   specify  the  maximum  values  that  can  be  assigned  to  each  of  the

                   variables BEGIN and LAST.                                                       2


                   import random
                   POINTS=[20,40,10,30,15];
                   POINTS=[30,50,20,40,45];


                   BEGIN=random.randint(1,3)
                   LAST=random.randint(2,4)
                   for C in range(BEGIN,LAST+1):
                     print POINTS[C],"#",



                     (i)  20#50#30#                       (ii)   20#40#45#


                     (iii) 50#20#40#                      (iv)  30#50#20#




      2.   (a)     What is the advantage of super( ) function in inheritance ? Illustrate
                   the same with the help of an example in Python.                                 2

           (b)     class Vehicle:                                          #Line 1                 2

                         Type = 'Car'                                      #Line 2
                         def __init__(self, name):                         #Line 3

                              self.Name = name                             #Line 4
                         def Show(self):                                   #Line 5

                              print self.Name,Vehicle.Type                 #Line 6


                   V1=Vehicle("BMW")                                       #Line 7
                   V1.Show()                                               #Line 8

                   Vehicle.Type="Bus"                                      #Line 9
                   V2=Vehicle("VOLVO")                                     #Line 10
                   V2.Show()                                               #Line 11


      91                                            14
   328   329   330   331   332   333   334   335   336   337   338