import numpy as np units = np.array([[3, 0, 2], [1, 4, 5]], dtype=np.float64) unit_prices = np.array([2.50, 4.00, 1.25]) store_fee = np.array([1.00, 1.50])[:, np.newaxis] subtotal = units * unit_prices total = subtotal + store_fee print("units shape:", units.shape) print("unit prices shape:", unit_prices.shape) print("store fee shape:", store_fee.shape) print("broadcast shape:", np.broadcast_shapes(units.shape, unit_prices.shape, store_fee.shape)) print("subtotal:") print(subtotal) print("total:") print(total)