Define a Python function named salesReport thathas two parameters. The first parameter will be a string specifyingthe name of the CSV file to write to (any existing contents shouldbe overwritten). The second parameter will be alist. Each entry in the first parameter is a list with 4 entriesrepresenting the following fields:
Author, Copies Sold Week 1, Copies Sold Week 2, Copies SoldWeek 3
(The value of Author is a str while all other values will beints).
For each entry in the 2nd parameter, you will need to write arow with containing the Author and thesum of the 3 “copies sold” fields in theCSV file.
Examples:
salesReport(“empty.csv”, [ ]) results in a file namedempty.txt existing, but not contain anycontents.
salesReport(“a.csv”, [ [“Bob Jones”, 100, 20, 0] ]) results in thefile a.csv containing exactly 1 row whose contentsare Bob Jones, 120.
Expert Answer
Answer to Define a Python function named salesReport that has two parameters. The first parameter will be a string specifying the …