Page 305 - C++
P. 305
CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
(Sub Code: 083 Paper Code 91 Outside Delhi)
Ans STRING="WELCOME"
NOTE=""
for S in range(0,8):
print STRING[S]
print S,STRING
Also range(0,8) will give a runtime error as the index is out of range. It should
be range(0,7)
(½ Mark for each for any four corrections)
OR
(1 mark for identifying the errors, without suggesting corrections)
(d) Find and write the output of the following python code: 2
TXT = ["20","50","30","40"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print TOTAL
CNT-=1
Ans 47.0
35.0
54.0
26.0
( ½ mark for each correct line of output)
NOTE:
Deduct ½ Mark for writing the answer in same line
Deduct ½ Mark for writing numbers without decimal point
(e) Find and write the output of the following python code: 3
class INVENTORY:
def __init__(self,C=101,N="Pad",Q=100): #constructor
self.Code=C
self.IName=N
self.Qty=int(Q);
def Procure(self,Q):
self.Qty = self.Qty + Q
def Issue(self,Q):
self.Qty -= Q
def Status(self):
print self.Code,":",self.IName,"#",self.Qty
I1=INVENTORY()
I2=INVENTORY(105,"Thumb Pin",50)
I3=INVENTORY(102,"U Clip")
I1.Procure(25)
I2.Issue(15)
I3.Procure(50)
I1.Status()
I3.Status()
Page #15 of 28