1.

Define a class ITEMINFO in Python with the following description:ICode (Item Code), Item (Item Name), Price (Price of each item), Qty (quantity in stock) Discount (Discount percentage on the item), Netprice (Final Price)Methods(i)  A member function FindDisc( ) to calculate discount as per the following rules:If Qty< = 10Discount is 0If Qty (11 to 20)Discount is 15If Qty > =20Discount is 20(ii) A constructor init method) to assign the value with 0 for ICode, Price, Qty, Netprice and Discountand null for Item respectively(iii) A function Buy( ) to allow user to enter values for ICode, Item, Price, Qty and call function FindDisc( )to calculate the discount and N etprice(Price * Qty-Discount).(iv) A Function ShowAll( ) to allow user to view the content of all the data members.

Answer»

class ITEMINFO:

#constructor to create an .object

def_init_(self):

#constructor

self.ICode=0

self.Item=‘ ’

self.Price=0.0

self.Qty=‘ ’

self.Discount=0

self.Netprice=0.0

def Buy(self):

self.ICode=input(“Enter Item Code”)

self. Item=raw_input(“Enter Item Name”)

self.Price=float(raw_input(“Enter Price”))

self.Qty=input(“Enter Quantity”)

def FindDisc(self):

if self.Qty <= 10:

self.Discount = 0

elif self.Qty >= 11 and self.Qty < 20 :

self.Discount = 15

else:

self.Discount = 20

self.Netprice= (self.Price*self.Qty)

self.Discount

def ShowAll(self):

print “Item Code’’,self.ICode

print “Item Name”,self.Item

print “Price”,self.Price

print “Quantity”,self.Qty

print “NetPrice”,self.Netprice

I = ITEMINFO()

I.Buy()

I.FindDisc()

I. Show All ()



Discussion

No Comment Found