In a class, there are three types of methods: instance methods, class methods, and static methods. Instance methods are defined with a mandatory parameter self, alongside any other required parameters. For class methods, we use the @classmethod decorator before the method and include a mandatory parameter named cls, along with other parameters. Static methods, on the other hand, don't require a decorator and function like normal Python functions without needing a mandatory parameter. When written within a class, they behave as static methods by default, but you can add clarity by using the @staticmethod decorator. Remember it's common practice to use decorators and highly recommended.
Thank You. That was a really concise explanation.
In a class, there are three types of methods: instance methods, class methods, and static methods. Instance methods are defined with a mandatory parameter
self
, alongside any other required parameters. For class methods, we use the@classmethod
decorator before the method and include a mandatory parameter namedcls
, along with other parameters. Static methods, on the other hand, don't require a decorator and function like normal Python functions without needing a mandatory parameter. When written within a class, they behave as static methods by default, but you can add clarity by using the@staticmethod
decorator. Remember it's common practice to use decorators and highly recommended.Why did you use @staticmethod on top of all the functions? (I am a newbie so pardon my questions)
In your problem I don't think you need a constructor(you can pass) for your given tasks.
I didn't think of that. Nice one.
We have a fun time ¯\(ツ)/¯
what are you guys doin here?
:)