Q:

Write a NumPy program to create a three-dimension array with shape (3,5,4) and set to a variable

0

Write a NumPy program to create a three-dimension array with shape (3,5,4) and set to a variable

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np  
nums = np.array([[[1, 5, 2, 1],
               [4, 3, 5, 6],
               [6, 3, 0, 6],
               [7, 3, 5, 0],
               [2, 3, 3, 5]],
              
              [[2, 2, 3, 1],
               [4, 0, 0, 5],
               [6, 3, 2, 1],
               [5, 1, 0, 0],               
               [0, 1, 9, 1]],
              
              [[3, 1, 4, 2],
               [4, 1, 6, 0],
               [1, 2, 0, 6],
               [8, 3, 4, 0],               
               [2, 0, 2, 8]]]) 
print("Array:")
print(nums)

Sample Output:

Array:
[[[1 5 2 1]
  [4 3 5 6]
  [6 3 0 6]
  [7 3 5 0]
  [2 3 3 5]]

 [[2 2 3 1]
  [4 0 0 5]
  [6 3 2 1]
  [5 1 0 0]
  [0 1 9 1]]

 [[3 1 4 2]
  [4 1 6 0]
  [1 2 0 6]
  [8 3 4 0]
  [2 0 2 8]]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now