I have a three question to ask
- in python I have written a class method inside a class and have written basic functionality When I try to call that method from class itself and when I try to print I get the output as "None"
- Also if someone can please explain in class methods only class variables can be accessed? and also can instance variables can also be accessed in class methods
- Also if remove the class variables and declare my own variables in the class method would the code will work when i pass the arguments in the method while calling it from class
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))