#numpy #python #programming #question #array #basic
Write a Python code snippet using NumPy to create a 2D array of shape (3, 4) filled with zeros. Then, modify the element at position (1, 2) to be 5. Print the resulting array.
Output:
By: @DataScienceQ 🚀
Write a Python code snippet using NumPy to create a 2D array of shape (3, 4) filled with zeros. Then, modify the element at position (1, 2) to be 5. Print the resulting array.
import numpy as np
# Create a 2D array of zeros with shape (3, 4)
arr = np.zeros((3, 4))
# Modify the element at position (1, 2) to be 5
arr[1, 2] = 5
# Print the resulting array
print(arr)
Output:
[[0. 0. 0. 0.]
[0. 0. 5. 0.]
[0. 0. 0. 0.]]
By: @DataScienceQ 🚀
❤2