q22.py
· 279 B · Python
原始檔案
# Using NumPy, write a program to create 1-dimensional array, load it with numbers, and perform the operation of
# iteration and slicing on it.
import numpy as np
print(arr := np.array([2, 3, 4, 1, 7, 6]))
for e in np.nditer(arr):
print(e, end=" ")
print()
print(arr[2:5])
1 | # Using NumPy, write a program to create 1-dimensional array, load it with numbers, and perform the operation of |
2 | # iteration and slicing on it. |
3 | |
4 | import numpy as np |
5 | |
6 | print(arr := np.array([2, 3, 4, 1, 7, 6])) |
7 | for e in np.nditer(arr): |
8 | print(e, end=" ") |
9 | print() |
10 | print(arr[2:5]) |
11 |