From d8adc75a00aebe16c680bf4167bb107073b845fb Mon Sep 17 00:00:00 2001 From: Donald Calloway Date: Mon, 29 Sep 2025 09:44:13 -0700 Subject: [PATCH] Modified code to target two slices of sales_data_2021 np array --- array_copying.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/array_copying.py b/array_copying.py index e61a325..12c2213 100644 --- a/array_copying.py +++ b/array_copying.py @@ -13,6 +13,7 @@ sales_data_2021 = np.array([[350, 420, 380, 410], [270, 320, 290, 310]]) # Create a copy of sales_data_2021 sales_data_2022 = np.copy(sales_data_2021) # Assign the NumPy array with elements 390 and 370 to the correct slice -sales_data_2022[0, -2:] = np.array([390, 370]) +sales_data_2022[0, -2:] = np.array([360, 420]) # Modify 1st element, Q3 & Q4 +sales_data_2022[1, :2] = np.array([280, 330]) # Modify 2nd element, Q1 & Q2 print(f'Quarterly sales in 2021:\n{sales_data_2021}') -print(f'Quarterly sales in 2022:\n{sales_data_2022}') \ No newline at end of file +print(f'Quarterly revised sales in 2022:\n{sales_data_2022}') \ No newline at end of file