How to create 2D array with numpy in Python

2 Answers

0 votes
import numpy 
  
arr = numpy.zeros((3, 2))

print(arr) 

'''
run:

[[0. 0.]
 [0. 0.]
 [0. 0.]]

'''

 



answered Jan 19, 2019 by avibootz
0 votes
import numpy 
  
arr = numpy.matrix([[1, 2], [3, 4], [5, 6]])

print(arr) 

'''
run:

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

'''

 



answered Jan 19, 2019 by avibootz

Related questions

1 answer 152 views
1 answer 229 views
1 answer 248 views
3 answers 315 views
1 answer 163 views
...