Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam PCPP-32-101 topic 1 question 7 discussion

Actual exam question from Python Institute's PCPP-32-101
Question #: 7
Topic #: 1
[All PCPP-32-101 Questions]

Analyze the following snippet and decide whether the code is correct and/or which method should be distinguished as a class method.

  • A. There is only one initializer, so there is no need for a class method
  • B. The getNumberOfCrosswords() method Should be decorated with @classmethod
  • C. The code is erroneous
  • D. The getNumberOfCrosswords() and isSolved methods should be decorated with @classmethod
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
pgcool
2 months, 3 weeks ago
The isElementCorrect method is decorated as a @staticmethod but incorrectly tries to call self.isSolved(), which is an instance method. Static methods do not have access to self because they do not require an instance of the class to be called. They work at the class level, not the instance level. C. The code is erroneous.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...