I have a three question to ask
Below is the code
class Item():
discount_price = 0.8
quantity1 = 10
quantity2 = 10
def __init__(self,name,price,quantity):
self.name = name
self.price = price
self.quantity = quantity
@classmethod
def year2020(cls,val1,val2):
cls.value2020 = cls.quantity1 + cls.quantity2 + cls.discount_price
print(Item.year2020(10,10))
The functoin year2020
does not return anything, so the print statement is told to print out nothing. To get it to print the output of the function, make sure to include a return
statement inside.
For example, here is a fixed function which returns the output:
def year2020(cls,val1,val2):
cls.value2020 = cls.quantity1 + cls.quantity2 + cls.discount_price
return cls.value2020