MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / compute_cost

Function compute_cost

src/1/mapping_names_to_sequence_elements/example1.py:7–12  ·  view source on GitHub ↗
(records)

Source from the content-addressed store, hash-verified

5Stock = namedtuple('Stock', ['name', 'shares', 'price'])
6
7def compute_cost(records):
8 total = 0.0
9 for rec in records:
10 s = Stock(*rec)
11 total += s.shares * s.price
12 return total
13
14# Some Data
15records = [

Callers 1

example1.pyFile · 0.85

Calls 1

StockClass · 0.50

Tested by

no test coverage detected