Skip to content

Commit 7116ff6

Browse files
committed
NumPy arrays - Adding elements, Removing elements
1 parent 367408c commit 7116ff6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

0008-Array-NumPy/array_numpy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@
88

99
NUMPY_ARRAY = np.array([2, 4, 6, 8, 10])
1010
print("NumPy array:", NUMPY_ARRAY)
11+
12+
# Adding elements - create a new array
13+
NEW_ARRAY = np.append(NUMPY_ARRAY, 6)
14+
print("After appending:", NEW_ARRAY)
15+
16+
# Removing elements - create a new array without the specific element
17+
NEW_ARRAY = np.delete(NUMPY_ARRAY, 2) # Deletes element at index 2 and add the result
18+
print("After removing:", NEW_ARRAY)

0 commit comments

Comments
 (0)