Which properties would you test for a basket discount calculation?
Instruction: Give runnable Python examples and generated invariants grounded in the specification. Explain a limitation of the chosen properties.
A pure Python function accepts a finite list of nonnegative integer prices in cents and an integer discount percentage from 0 through 100. Booleans and non-integer values are invalid and raise ValueError. It sums the basket, calculates the discount on that total, rounds the discount down to a whole cent once, then subtracts it. Empty baskets return zero. Write a small implementation and a standard-library test fixture, or equivalent property-based tests. Do not round each line separately.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
I would anchor the rounding rule with examples before generating cases. For 101 cents at 50%, the discount rounds down to 50 cents and the payable total is 51...
Related Questions
-
easy
-
easy
-
easy
-
easy
-
easy
-
easy