Intermediate Python
Q42 / 101

What is the difference between @staticmethod and @classmethod?

Correct! Well done.

Incorrect.

The correct answer is B) @staticmethod receives no implicit argument; @classmethod receives cls (the class) as the first argument

B

Correct Answer

@staticmethod receives no implicit argument; @classmethod receives cls (the class) as the first argument

Explanation

staticmethod has no access to instance or class. classmethod gets cls, useful for alternative constructors and factory methods.

Progress
42/101