State and side effects in a counter class

Consider this Python code, which defines a class and then makes three method calls on two objects.


Python
class Counter:
    def __init__(self):
        self.count = 0

    def bump(self):
        self.count += 1
        return self.count

a = Counter()
b = Counter()
a.bump()
a.bump()
b.bump()


Which of the following statements are true? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Procedural, Functional, Logical and Object-Oriented Paradigms Questions: