Write a NumPy program to fetch all items from a given array of 4,5 shape which are either greater than 6 and a multiple of 3
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
array_nums1 = np.arange(20).reshape(4,5)
print("Original arrays:")
print(array_nums1)
result = array_nums1[(array_nums1>6) & (array_nums1%3==0)]
print("\nItems greater than 6 and a multiple of 3 of the said array:")
print(result)
Sample Output:
Original arrays: [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19]] Items greater than 6 and a multiple of 3 of the said array: [ 9 12 15 18]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال