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

Function make_report_data

Solutions/4_4/report.py:26–37  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected