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

Function make_report_data

Solutions/7_4/report.py:29–40  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected