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

Function make_report_data

Solutions/2_11/report.py:39–50  ·  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

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

Callers 1

report.pyFile · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected