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

Function make_report_data

Solutions/3_2/report.py:40–51  ·  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

38 return prices
39
40def make_report_data(portfolio,prices):
41 '''
42 Make a list of (name, shares, price, change) tuples given a portfolio list
43 and prices dictionary.
44 '''
45 rows = []
46 for stock in portfolio:
47 current_price = prices[stock['name']]
48 change = current_price - stock['price']
49 summary = (stock['name'], stock['shares'], current_price, change)
50 rows.append(summary)
51 return rows
52
53def print_report(reportdata):
54 '''

Callers 1

portfolio_reportFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected