SKILLIFYME: NUMPY ASSESSMENT TEST
Instructions: For each task, create a fresh NumPy array. This ensures you are working with a fresh
dataset for each operation. Read each task carefully and solve the problems using NumPy. Write
efficient and clean code for each task.
Sales Data Context: You are a data analyst at Flipkart, and you’ve been given sales data for 7 days
(Monday to Sunday) for 5 products. The task is to work with this data to extract useful insights and
perform various array manipulations using NumPy.
# 5 products × 7 days (Mon to Sun)
[50, 60, 55, 70, 65, 80, 75] # Product 1
[40, 42, 38, 45, 50, 60, 58] # Product 2
[30, 35, 32, 28, 40, 45, 50] # Product 3
[20, 25, 22, 30, 28, 35, 38] # Product 4
[70, 65, 80, 90, 85, 95, 100] # Product 5
Tasks:
1. Create a fresh NumPy array for the sales data of 5 products and 7 days. Print the array.
2. Find and print the shape of the sales_data array (i.e., how many rows and columns).
3. Access and print the sales data of Product 1 on Friday.
4. Access and print the sales for Product 2 and Product 5 on Days 1, 3, and 5.
5. Access and print all sales data except Sunday (remove the last column).
SKILLIFYME: NUMPY ASSESSMENT TEST
Instructions: For each task, create a fresh NumPy array. This ensures you are working with a fresh
dataset for each operation. Read each task carefully and solve the problems using NumPy. Write
efficient and clean code for each task.
Sales Data Context: You are a data analyst at Flipkart, and you’ve been given sales data for 7 days
(Monday to Sunday) for 5 products. The task is to work with this data to extract useful insights and
perform various array manipulations using NumPy.
# 5 products × 7 days (Mon to Sun)
[50, 60, 55, 70, 65, 80, 75] # Product 1
[40, 42, 38, 45, 50, 60, 58] # Product 2
[30, 35, 32, 28, 40, 45, 50] # Product 3
[20, 25, 22, 30, 28, 35, 38] # Product 4
[70, 65, 80, 90, 85, 95, 100] # Product 5
Tasks:
1. Create a fresh NumPy array for the sales data of 5 products and 7 days. Print the array.
2. Find and print the shape of the sales_data array (i.e., how many rows and columns).
3. Access and print the sales data of Product 1 on Friday.
4. Access and print the sales for Product 2 and Product 5 on Days 1, 3, and 5.
5. Access and print all sales data except Sunday (remove the last column).
6. Add 5 to all Thursday sales (index 3).
7. Multiply the Saturday and Sunday sales by 2.
8. Find and print the total sales for each day (i.e., sum across products for each day).
9. Find and print the maximum and minimum sales value across all products and days.
10. Find and print the total sales for the weekend (Saturday and Sunday).
11. Find and print the average sales on Sunday (across all products).
12. Create a copy of the sales data and update Product 1's Monday sales (index 0) to 100. Show both
the original and modified arrays.
13. Create a view of the sales data and modify Product 2's Tuesday sales (index 1) to 99. Show both
the original and modified arrays.
14. Flatten the entire sales_data matrix into a 1D array. Print the number of elements in the flattened
array.
15. Replace all values less than 30 with the minimum value, and all other values with the maximum
value.
16. Compute and print the mean, median, and standard deviation of the entire sales_data array.
17. Sort the sales data row-wise (each product’s sales in ascending order).
18. Extract and print all sales that are multiples of 10.
19. Find and count how many sales values are divisible by 3 or 7.
20. Square the sales for odd-numbered days (Tuesday, Thursday, Saturday) for all products.
6. Add 5 to all Thursday sales (index 3).
7. Multiply the Saturday and Sunday sales by 2.
8. Find and print the total sales for each day (i.e., sum across products for each day).
9. Find and print the maximum and minimum sales value across all products and days.
10. Find and print the total sales for the weekend (Saturday and Sunday).
11. Find and print the average sales on Sunday (across all products).
12. Create a copy of the sales data and update Product 1's Monday sales (index 0) to 100. Show both
the original and modified arrays.
13. Create a view of the sales data and modify Product 2's Tuesday sales (index 1) to 99. Show both
the original and modified arrays.
14. Flatten the entire sales_data matrix into a 1D array. Print the number of elements in the flattened
array.
15. Replace all values less than 30 with the minimum value, and all other values with the maximum
value.
16. Compute and print the mean, median, and standard deviation of the entire sales_data array.
17. Sort the sales data row-wise (each product’s sales in ascending order).
18. Extract and print all sales that are multiples of 10.
19. Find and count how many sales values are divisible by 3 or 7.
20. Square the sales for odd-numbered days (Tuesday, Thursday, Saturday) for all products.