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

Function make_report_data

Solutions/3_18/report.py:20–31  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected