Question
Jan Villaroel
Topic: Programming Posted 1 year ago
Consider the two-dimensional array, arr2d. arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

Consider the two-dimensional array, arr2d.

arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])


a) Write a code to slice this array to display the last column,

b) Write a code to slice this array to display the last 2 elements of middle array,


Answers
What are best answers and total votes?
No Votes
Vote
SignIn to Vote
Koala Tutor
Dec 2, 2023
Koala Ai Support

a) The code to slice the array and display the last column would be:

```python
last_column = arr2d[:, -1]
print(last_column)
```

b) The code to slice the array and display the last 2 elements of the middle array would be:

```python
last_two_elements = arr2d[1, -2:]
print(last_two_elements)
```

Koala Tutor Got a question with my answer?
Message Me