import numpy as np
a = np.array([1, 4, 5, 8], float)
print(a)
print( type(a) )
print( a[:2] ) #print up to the 3rd element
print( a[3] ) #print the 4th element
Just PressRun
.
Arrays can be multidimensional. Unlike lists, different axes are accessed using commas inside
bracket notation. Here is an example with a two-dimensional array (e.g., a matrix)
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]], float)
print( a )
print( a[0,0] ) #print element at (0,0)
print( a[0,1] )
print( a[1,:] ) # Array slicing
print( a.shape )
print( a.len )
Just PressRun
.