A reading challenge calculates reward points with the following Python code. For books = 5 and returned_on_time = False, what is the final value of points? Answer in points, to the nearest whole point.
points = 9 if books >= 3: points = points + 7 if returned_on_time: points = points * 2 else: points = points - 4 points = points + 3
Unlock full course notes by signing up
Which output claims follow?
A file-opening program uses the following Python code. Select every statement that correctly describes its output for the specified input conditions.
Both inputs store either True or False, and execution always reaches the end of this code.
Count the tests that actually run
A dispatch program runs the following Python code once for each parcel. The variable mass gives the parcel mass in kilograms; express and fragile contain Boolean values.
Count a condition evaluation whenever execution reaches an if and tests its condition. An else does not perform another test.
Across these four independent runs, find the total number of condition evaluations and the number of those evaluations that return true. Enter both counts as exact integers.
The cost of moving an else
A festival checkout has two versions of its ticket-pricing code. Each version starts independently, and both inputs are either True or False.
Program A
Program B