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
price = 40 if has_pass: price = 28 if evening: price = 22 else: price = 25
Program B
Across all four combinations of the two inputs, how many combinations produce different final prices in the two programs? Also find each program's final price when has_pass = False and evening = True. Give the count as an exact integer and both prices in dollars to the nearest whole dollar.
Unlock full course notes by signing up
Carry values through a nested path
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.
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.