All problems

Products Under the No-Paperwork Cap

easyPythonFilteringSorting

Whetcode Supply sells office kit to companies, and the expense policy its customers use reimburses an accessory on the spot only if it costs less than the customer's own cap. Anything from the cap up needs a manager's signature first. Every customer sets a different cap, so marketing builds one "no paperwork needed" page per customer, listing exactly the products that clear that bar, cheapest first, so the easiest purchase sits at the top and does the work of pulling people in. A product priced right on the line is the whole reason the page exists — get it wrong and buyers hit a signature they were promised they would not.

The other catch is the gap between what the page shows and what decides its order: the page prints product names, but the order is settled by a number the reader never sees.

products_df — the catalogue, one row per product. price is the cost of a single unit, in dollars.

id name category price
1 Wireless Mouse electronics 25.0
2 Standing Desk furniture 350.0
3 Desk Lamp furniture 40.0
4 Mechanical Keyboard electronics 85.0
5 Notebook Set office 12.0

Input

The DataFrame above is already built for you — the catalogue is not read from input. What does arrive is a single line holding this customer's cap, a price in dollars.

Task: Print a Python list of the names of every product priced under the cap that arrives, ordered cheapest first. A product priced at exactly the cap does not belong on the page.

Example: if only two products were cheap enough, the output would look like ['Cheapest Thing', 'Slightly Pricier Thing'].

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…