Write a NumPy program to get the number of items, array dimensions, number of array dimensions and the memory size of each element of a given array
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
array_nums = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
print("Original array:")
print(array_nums)
print("\nNumber of items of the said array:")
print(array_nums.size)
print("\nArray dimensions:")
print(array_nums.shape)
print("\nNumber of array dimensions:")
print(array_nums.ndim)
print("\nMemory size of each element of the said array")
print(array_nums.itemsize)
Sample Output:
Original array: [[ 1 2 3 4] [ 5 6 7 8] [ 9 10 11 12]] Number of items of the said array: 12 Array dimensions: (3, 4) Number of array dimensions: 2 Memory size of each element of the said array 8
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال