Calculate Cumulative Sum Using np.cumsum()
📖 Scenario: Imagine you have daily sales numbers for a small shop. You want to see how sales add up day by day to understand the total sales over time.
🎯 Goal: You will create a list of daily sales, then use np.cumsum() to find the running total of sales each day.
📋 What You'll Learn
Create a numpy array called
daily_sales with exact values: 5, 10, 7, 3, 8Create a variable called
cumulative_sales that stores the cumulative sum of daily_sales using np.cumsum()Print the
cumulative_sales array💡 Why This Matters
🌍 Real World
Cumulative sums are used in finance to track total earnings, in health to track total steps walked, and in sales to track total revenue over time.
💼 Career
Data analysts and scientists often use cumulative sums to understand trends and totals in datasets, making this a key skill for reporting and decision-making.
Progress0 / 4 steps