Drill

ProblemsPython › orders

Does this basket ship free

easyordersPython

The storefront shows a "free shipping" badge, but the rule has an exception for heavy baskets that finance insisted on.

ships_free(basket_total: int, grams: int, threshold: int) → bool

Solve it in the editor →

Where you start

def ships_free(basket_total: int, grams: int, threshold: int) -> bool:
    

Worked examples

CallResult
ships_free(50000, 3000, 30000)True
ships_free(50000, 25000, 30000)False
ships_free(30000, 1000, 30000)True
ships_free(29999, 1000, 30000)False

Hint

The weight rule overrides the value rule, so check it second — or check it first and return early.

Reference solution in Python
def ships_free(basket_total: int, grams: int, threshold: int) -> bool:
    if basket_total <= 0 or grams > 20000:
        return False
    return basket_total >= threshold

The same problem in another language

More orders problems in Python