You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
question="Which decorator is used to define a method that belongs to the class rather than an instance?",
152
-
options={
153
-
"@staticmethod": "Incorrect. A static method does not belong to the class or instance.",
154
-
"@classmethod": "Correct! A class method belongs to the class and takes `cls` as its first parameter.",
155
-
"@property": "Incorrect. The `@property` decorator is used to define getter methods.",
156
-
"@abstractmethod": "Incorrect. The `@abstractmethod` decorator is used in abstract classes.",
157
-
},
158
-
correct_answer="@classmethod",
159
-
hint="This method takes `cls` as its first parameter.",
160
-
shuffle=True,
161
-
)
162
-
163
-
q6=Question(
164
151
question="What is the purpose of the `@classmethod` decorator?",
165
152
options={
166
153
"To define a method that belongs to the class rather than an instance": "Correct! A class method belongs to the class and takes `cls` as its first parameter.",
@@ -173,7 +160,7 @@ def __init__(self, title=""):
173
160
shuffle=True,
174
161
)
175
162
176
-
q7=Question(
163
+
q6=Question(
177
164
question="What is the difference between `@staticmethod` and `@classmethod`?",
178
165
options={
179
166
"`@staticmethod` does not access the class or instance, while `@classmethod` takes `cls` as its first parameter": "Correct! This is the key difference between the two decorators.",
0 commit comments