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.
stock = {"pens": 12, "pads": 7} old_pens = stock["pens"] stock["pens"] -= 5 stock["pads"] += 3 stock["clips"] = 4
Unlock full course notes by signing up
A mutable list inside an immutable tuple
A Python program stores a category and a list of measurements in the tuple below. Consider each proposed operation independently, starting from this initial value. Which statements are true? Select all that apply.
Changes inside a copied two-dimensional list
A Python program represents two rows of sample counts using lists. It creates a copy and then makes the changes shown below. After every statement executes, find the total of all entries in grid and the total of all entries in snapshot. Count every row position, even when two positions contain the same list. Give both totals as exact whole-number counts, with no decimal places.
Shared batch lists created by a dictionary default
A workshop records batch sizes, in parts, for morning and evening production. Each list entry represents one batch. The Python method dict.fromkeys(keys, value) creates a dictionary that stores the same supplied value under every key; it does not copy that value.
Here, append adds one entry, extend adds each entry from the supplied list, and remove deletes the first matching entry. After all statements execute, determine the total parts in the morning list, the total parts in the evening list, and the number of batches in saved. Enter exact integers in the indicated units.