IntermediateFiles & CSV25 points

Sales report for a category

A store exports its daily sales to sales.csv (see the file below). The manager asks you for a quick report on one product category at a time.

Task: read a category name from the input. Using sales.csv, the revenue of a row is qty × unit_price. Print two lines:

  • Total revenue: X (the total revenue of that category as a whole number)
  • Best product: NAME (the product with the highest revenue in that category)

Category names match exactly as written in the file.

Files your program can read

sales.csv13 lines
date,product,category,qty,unit_price
2026-03-01,Wireless Mouse,Electronics,3,1850
2026-03-01,Notebook A4,Stationery,20,220
2026-03-02,Basmati Rice 5kg,Grocery,6,1450
2026-03-02,USB Cable,Electronics,10,450
2026-03-03,Gel Pen Pack,Stationery,15,180
2026-03-03,Bluetooth Speaker,Electronics,2,4200
2026-03-04,Olive Oil 1L,Grocery,4,1650
...

Open them by name, for example open("sales.csv").

Sample test

Input

Electronics

Expected output

Total revenue: 31450
Best product: Power Bank 10000mAh

Your answer is also checked against 2 hidden tests.

Need a hint?

Use the csv module with DictReader, and keep a dictionary of revenue per product.