0
0
Data Analysis Pythondata~15 mins

Array arithmetic (element-wise) in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Array arithmetic (element-wise)
📖 Scenario: You work in a small shop that tracks daily sales of two products. You want to quickly find the total sales each day by adding the sales of both products.
🎯 Goal: Build a simple program that creates two lists of daily sales numbers, then adds them element-wise to find total daily sales.
📋 What You'll Learn
Create two lists named sales_product_a and sales_product_b with exact daily sales numbers
Create a variable named days to store the number of days
Use a for loop with index variable i to add sales element-wise
Store the element-wise sums in a list named total_sales
Print the total_sales list
💡 Why This Matters
🌍 Real World
Shops and businesses often track daily sales of multiple products. Adding sales data element-wise helps find total sales per day quickly.
💼 Career
Data analysts and scientists frequently perform element-wise operations on arrays or lists to combine or compare data from different sources.
Progress0 / 4 steps
1
Create daily sales lists
Create a list called sales_product_a with values [10, 15, 20, 25, 30] and a list called sales_product_b with values [5, 10, 15, 20, 25].
Data Analysis Python
Need a hint?

Use square brackets [] to create lists with the exact numbers given.

2
Set the number of days
Create a variable called days and set it to the length of the sales_product_a list using the len() function.
Data Analysis Python
Need a hint?

Use len(sales_product_a) to find how many days of sales data there are.

3
Add sales element-wise
Create an empty list called total_sales. Use a for loop with index variable i from 0 to days - 1. Inside the loop, add sales_product_a[i] and sales_product_b[i] and append the result to total_sales.
Data Analysis Python
Need a hint?

Use range(days) to loop over all days and append() to add sums to the list.

4
Print the total sales
Write a print() statement to display the total_sales list.
Data Analysis Python
Need a hint?

Use print(total_sales) to show the final list of sums.