Q:

Write a NumPy program to view inputs as arrays with at least two dimensions, three dimensions

0

Write a NumPy program to view inputs as arrays with at least two dimensions, three dimensions.

All Answers

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

import numpy as np
x = 10
print("View inputs as arrays with at least two dimensions:")
print(np.atleast_1d(x))
x = np.arange(4.0).reshape(2, 2)
print(np.atleast_1d(x))
print("View inputs as arrays with at least three dimensions:")
x =15
print(np.atleast_3d(x))
x = np.arange(3.0)
print(np.atleast_3d(x))

Sample Output:

View inputs as arrays with at least two dimensions:                    
[10]                                                                   
[[ 0.  1.]                                                             
 [ 2.  3.]]                                                            
View inputs as arrays with at least three dimensions:                  
[[[15]]]                                                               
[[[ 0.]                                                                
  [ 1.]                                                                
  [ 2.]]]

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