runtime
399 / 500
question 399 Software Architecture · hard

An entry point over the ratings modules

ratings.py (read-only) holds the pure core: parse_ratings(text) and averages(rows). Write the entry point main(argv): argv is [input_csv, output_json] with an optional --min N after them; read the CSV, compute the averages, keep products whose average is at least N (default 0), write them as a JSON object to the output file and return 0. A missing input file prints error: <path> not found and returns 1; wrong arguments return 2.

Functionmain(argv) → exit code
argv[in_csv, out_json] or [in_csv, out_json, "--min", "4"]
OutputJSON object {product_id: average} of the kept products
Codes0 success; 1 input missing (with the message printed); 2 wrong arguments

Loading your progress…

An entry point over the ratings modules — Python practice · Runtime