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

Exam PCPP-32-101 All Questions

View all questions & answers for the PCPP-32-101 exam

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 (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
herrmann69
5 months, 3 weeks ago
Selected Answer: C
Answer C is correct - the code has errors As pgcool already wrote: isElementCorrect is decorated with@staticmethod, but uses self, which is undefined
upvoted 2 times
...
pgcool
9 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 4 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 ...