MCPcopy Index your code
hub / github.com/dabeaz-course/practical-python / make_report_data

Function make_report_data

Solutions/4_10/report.py:27–38  ·  view source on GitHub ↗

Make a list of (name, shares, price, change) tuples given a portfolio list and prices dictionary.

(portfolio, prices)

Source from the content-addressed store, hash-verified

25 return dict(fileparse.parse_csv(lines, types=[str,float], has_headers=False))
26
27def make_report_data(portfolio, prices):
28 '''
29 Make a list of (name, shares, price, change) tuples given a portfolio list
30 and prices dictionary.
31 '''
32 rows = []
33 for s in portfolio:
34 current_price = prices[s.name]
35 change = current_price - s.price
36 summary = (s.name, s.shares, current_price, change)
37 rows.append(summary)
38 return rows
39
40def print_report(reportdata, formatter):
41 '''

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected