QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12D-2017-B01E #6400

Question:

Find and write the output of the following python code:

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
I1=ITEM()
I2=ITEM(100,"Eraser",100)
I3=ITEM(102,"Sharpener")
I1.Buy(10)
I2.Sell(25)
I3.Buy(75)
I3.ShowStock()
I1.ShowStock()
I2.ShowStock()

Answer:

102 : Sharpener # 85
101 : Pen # 20
100 : Eraser # 75