Write a NumPy program to create two arrays of size bigger and smaller than a given array
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
x = np.arange(16).reshape(4,4)
print("Original arrays:")
print(x)
print("\nArray with size 2x2 from the said array:")
new_array1 = np.resize(x,(2,2))
print(new_array1)
print("\nArray with size 6x6 from the said array:")
new_array2 = np.resize(x,(6,6))
print(new_array2)
Sample Output:
Original arrays: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]] Array with size 2x2 from the said array: [[0 1] [2 3]] Array with size 6x6 from the said array: [[ 0 1 2 3 4 5] [ 6 7 8 9 10 11] [12 13 14 15 0 1] [ 2 3 4 5 6 7] [ 8 9 10 11 12 13] [14 15 0 1 2 3]]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال