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

Function make_report

Solutions/8_1/report.py:23–34  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected