Page 234 - C++
P. 234
SECTION – B
(Only for Candidates, who opted for Python)
1. (a) Which of the following can be used as valid variable identifier(s) in Python ? 2
(i) total
(ii) 7Salute
(iii) Que$tion
(iv) global
(b) Name the Python Library modules which need to be imported to invoke the
following functions : 1
(i) ceil()
(ii) randint()
(c) Rewrite the following code in Python after removing all syntax error(s). Underline
each correction done in the code. 2
TEXT=""GREAT
DAY""
for T in range[0,7]:
print TEXT(T)
print T+TEXT
(d) Find and write the output of the following Python code : 2
STR = ["90","10","30","40"]
COUNT = 3
SUM = 0
for I in [1,2,5,4]:
S = STR[COUNT]
SUM = float (S)+I
print SUM
COUNT–=1
(e) Find and write the output of the following Python code : 3
class ITEM:
def_init_(self,I=101,N="Pen",Q=10): #constructor
self.Ino=I
self.IName=N
self.Qty=int(Q);
def Buy(self,Q):
self.Qty = self.Qty + Q
def Sell(self,Q):
self.Qty –= Q
def ShowStock(self):
print self.Ino,":",self.IName,"#",self.Qty
91/1 9 [P.T.O.