Project 29: Shopping Cart Calculator
Data Engineer
Builds on these lessons
Current Task
Objective
Final challenge: combine element-wise arithmetic, aggregation, and boolean filtering — the three techniques you've used all track — into one real cart calculation.
Task: compute each line's total (price * quantity), the cart's overall total, and the subset of items priced over $20.
index.py
import numpy as np
prices = np.array([19.99, 5.50, 42.00, 12.25])
quantities = np.array([2, 5, 1, 3])
line_totals = prices * quantities
cart_total = np.sum(line_totals)
big_items = prices[prices > 20]
print(round(cart_total, 2))
print(big_items)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview