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
|
313 Discussions
|
Please Login in order to post a comment
BY GK import numpy
arr = input().strip().split(' ') array = numpy.array(arr,dtype="int32")
N1 = numpy.zeros(array,dtype="int32") print(N1)
N1 = numpy.ones(array,dtype="int32") print(N1)
Here is HackerRank Zeros and Ones in Python solution - https://programmingoneonone.com/hackerrank-zeros-and-ones-problem-solution-in-python.html
import numpy user_input = input().split() d =tuple(map(int,user_input)) print(numpy.zeros((d),dtype = 'int')) print(numpy.ones((d),dtype = 'int'))
Here is the solution :)
import numpy as np
n = input()
l1 = list(map(int,n.split(' ')))
arr = np.zeros((l1),dtype=int) print(arr) arr = np.ones((l1),dtype=int) print(arr)