We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Zeros and Ones
- Discussions
Zeros and Ones
Zeros and Ones
Sort by
recency
|
283 Discussions
|
Please Login in order to post a comment
import numpy
shape = tuple(map(int, input().split(' ')))
print(numpy.zeros(shape, int)) print(numpy.ones(shape, int))
import numpy
a= list(map(int, input().split()))
print(numpy.zeros(a, dtype = numpy.int)) print(numpy.ones(a, dtype = numpy.int))
Using dtype=numpy.int is not valid anymore in the current stable release of numpy module. Use dtype=int
zero_matrix = np.zeros((3,3),dtype=int) print(zero_matrix)
zero_matrix_again = np.zeros((3,3),dtype=int) print(zero_matrix_again)
zero_matrix_third = np.zeros((3,3),dtype=int) print(zero_matrix_third)
one_matrix = np.ones((3,3),dtype=int) print(one_matrix)
one_matrix_again = np.ones((3,3),dtype=int) print(one_matrix_again)
one_matrix_third = np.ones((3,3),dtype=int) print(one_matrix_third)