A delivery service accepts packages weighing 1–2000 g inclusive. Assume every supplied weight is an integer. A reviewer compares the function’s docstring with its implementation, including calls outside the permitted range. Which finding correctly identifies a documentation discrepancy?
def delivery_cost(weight_g): """Return delivery cost in cents. weight_g must be an integer from 1 to 2000 inclusive. Return 400 for weights up to 1000 g, otherwise 700. Raise ValueError for weights outside the permitted range. """ if weight_g > 2000: raise ValueError("Too heavy") if weight_g <= 1000: return 400 return 700
The upper limit fails because a weight of 2000 g raises an error.
The error promise fails because a weight of 0 g returns 400 cents.
The price boundary fails because a weight of 1000 g costs 700 cents.
The error promise holds because all permitted weights receive valid prices.
Unlock full course notes by signing up
Measure the effect of an outdated docstring
A rental kiosk charges for every started minute. Its implementation follows that policy, but its docstring has not been updated. All durations supplied are nonnegative integers in seconds.
For a session lasting 194 s, by how many minutes does the actual return value exceed the result described by the docstring? Answer in minutes as an exact integer.
Document changes visible to the caller
A notification function receives an ordinary Python list of strings named tags and a string named tag. The current docstring omits details that callers need. Which statements accurately describe the shown function? Select all that apply.
Track units through a readable booking calculation
A booking program uses a unit-bearing identifier, a name that includes the measurement unit, for each monetary amount. Read the Python code and complete the table with the exact values stored after execution. Enter integers for amounts in cents and an exact decimal for the amount in dollars. The service fee applies once per booking.
Arrange a source file for predictable navigation
A team uses source-file organization, the arrangement of a file's sections, to help readers locate information. Arrange the Python blocks from top to bottom according to the team's documented layout:
The file description is the first statement, so Python recognizes it as the module's docstring.
Imports come before configuration constants.