In Python, Counter(n) creates a new object with its own stored count initially equal to nnn. Calling increment(k) adds kkk 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:
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.
The variables main and mirror refer to one object whose final count is 13.
The object referenced by separate finishes with a count of 15 because all increments accumulate.
The three variables collectively refer to exactly two Counter objects after these statements run.
Assigning main to mirror creates another Counter object with its own independent count.
Unlock full course notes by signing up
Follow one robot's charge
Two separate Robot objects, rover and scout, store their own battery charge percentages. Initially, rover has 54% charge and scout has 73% charge. The methods subtract or add the stated number of percentage points to the target robot's charge.
The following calls occur in order, and all succeed:
rover.consume(17)
Check requests before changing state
Two separate SnackDispenser objects, A and B, each hold at most 20 packets. Initially, A holds 8 packets and B holds 13 packets.
For each positive integer request, vend(k) removes exactly kkk packets if enough are available. The method load(k) adds exactly kkk packets if the resulting stock does not exceed 20. Otherwise, the request is rejected and the target object's stock stays unchanged. Neither method changes the other object.
Complete the table after each call, processing the rows from top to bottom. Enter yes or no for acceptance and exact integers for both stock counts.
Recognize the principles in a drawing application
A team describes four features of a drawing application. Match each object-oriented principle to the description that most directly illustrates it. Each description has one intended match.
Audit charges selected by runtime class
A parcel application uses the following class rules. All charges are in dollars, and no taxes or other fees apply.
Parcel.fee() returns 4.00plus4.00 plus 4.00plus1.50 per kilogram of mass.
InsuredParcel specializes Parcel and overrides fee(). Its method calculates the charge using the Parcel formula, then adds 2% of the declared value.