MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / make_report_data

Function make_report_data

Solutions/6_12/report.py:28–39  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected