Order value histogram
A pricing analyst wants to see how order values are spread before choosing free-shipping limits. Orders are in orders.csv.
order_id,country,categoryunits: items in the orderunit_price: USD per item (whole number)order_date: YYYY-MM-DD
Task: the first input line is a bucket width W (positive integer), the second line is a country or the word ALL for every country. The value of an order is units x unit_price. Order value V falls in the bucket starting at (V // W) * W. Print one line per bucket, including empty ones, from the bucket 0 up to the bucket of the largest value, formatted LOW-HIGH: COUNT with HIGH = LOW + W - 1 (for example 0-499: 12). If no order matches print No orders.
Files your program can read
order_id,country,category,units,unit_price,order_date O-10001,Mexico,Toys,1,46,2025-02-05 O-10002,Brazil,Toys,12,40,2025-03-31 O-10003,United Kingdom,Toys,3,46,2025-06-17 O-10004,Mexico,Books,3,24,2025-05-17 O-10005,Canada,Electronics,2,278,2025-02-25 O-10006,India,Books,8,21,2025-04-15 O-10007,India,Books,5,22,2025-01-24 ...
Open them by name, for example open("orders.csv").
Sample test
Input
500 ALL
Expected output
0-499: 166 500-999: 40 1000-1499: 15 1500-1999: 3 2000-2499: 3 2500-2999: 1 3000-3499: 8 3500-3999: 3 4000-4499: 0 4500-4999: 1
Your answer is also checked against 4 hidden tests.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
