Python Data Science Jobs & Interviews
20.3K subscribers
187 photos
4 videos
25 files
325 links
Your go-to hub for Python and Data Science—featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
#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.

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