A warehouse program stores two checkpoint counts. It saves the original tuple, reverses the positions by constructing another tuple, and then applies two count corrections:
checkpoints = (12, 18) saved = checkpoints checkpoints = (checkpoints[1], checkpoints[0]) checkpoints = (checkpoints[0] + 5, checkpoints[1] + 2)
After all four lines run, give the first count in checkpoints, the second count in checkpoints, and the first count in saved. Enter each count as an exact whole number.
Unlock full course notes by signing up
Calculate with unpacked dimensions
A delivery program stores a parcel's length, width, and height in centimetres, in that order. It runs the following code:
What value does difference contain? Answer in centimetres, to the nearest whole centimetre.
Separate tuple changes from variable changes
A program begins with record = (6, 10). Consider each proposed operation independently, starting from this original assignment each time. Select every statement that correctly describes Python's behaviour.
Count elements at the correct tuple level
A sensor program groups the same three readings in three different ways. A nested tuple contains another tuple as an element.
Complete the table with exact integer counts. Count only elements directly inside the outer tuple. In the final column, count how many of those outer elements are themselves tuples.
Recover from a malformed measurement tuple
A technician's program stores three cable lengths in metres. The first assignment unpacks a grouped measurement record. The next assignment attempts to replace those measurements.
Python raises a ValueError when an unpacking level has the wrong number of values. The except block catches that error; pass performs no action, and execution continues after the block.
Determine the final values of total and spread. Enter both in metres as exact integers.