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

Function make_report_data

Solutions/3_16/report.py:18–29  ·  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

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

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected