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

Function print_report

Solutions/8_1/report.py:36–43  ·  view source on GitHub ↗

Print a nicely formated table from a list of (name, shares, price, change) tuples.

(reportdata, formatter)

Source from the content-addressed store, hash-verified

34 return rows
35
36def print_report(reportdata, formatter):
37 '''
38 Print a nicely formated table from a list of (name, shares, price, change) tuples.
39 '''
40 formatter.headings(['Name','Shares','Price','Change'])
41 for name, shares, price, change in reportdata:
42 rowdata = [ name, str(shares), f'{price:0.2f}', f'{change:0.2f}' ]
43 formatter.row(rowdata)
44
45def portfolio_report(portfoliofile, pricefile, fmt='txt'):
46 '''

Callers 1

portfolio_reportFunction · 0.70

Calls 2

headingsMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected