Keeping an earlier inventory count

A stationery cupboard tracks item counts in a Python dictionary. Run the following code mentally, then complete the table with the final counts. Enter exact integers in items.


Python
stock = {"pens": 12, "pads": 7}
old_pens = stock["pens"]
stock["pens"] -= 5
stock["pads"] += 3
stock["clips"] = 4
Quantity after executionCount (items)
stock pens entry
stock pads entry
stock clips entry
old_pens

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 Mutable vs Immutable Questions: