Separate names from objects

In Python, Counter(n) creates a new object with its own stored count initially equal to nn. Calling increment(k) adds kk to that object's count. Assigning an existing object to another variable gives that variable a reference to the same object.


The following statements run in order:


Python
main = Counter(6)
mirror = main
separate = Counter(6)
main.increment(4)
mirror.increment(3)
separate.increment(2)


Which statements about the final counts and object identities 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 The Object-Oriented Paradigm Questions: