Zeros and Ones

Sort by

recency

|

323 Discussions

|

  • + 0 comments
    import numpy
    l=list(map(int,input().split()))
    print(numpy.zeros((l),dtype=int))
    print(numpy.ones((l),dtype=int))
        
    
  • + 0 comments

    import numpy as np n = tuple(map(int, input().split()))

    print(np.zeros(n).astype(int)) print(np.ones(n).astype(int))

  • + 0 comments

    For Python3 Platform

    No need to use numpy.int. Just type "int" as this is being accepted in the new versions of numpy module. Hackerrank should take a look at the synopsis they have given for this problem

    import numpy
    
    lst = [*map(int, input().split())]
    
    print(numpy.zeros(lst, dtype=int))
    print(numpy.ones(lst, dtype=int))
    
  • + 0 comments
    import numpy as np
    shape = tuple(map(int,input().split()))
    print(np.zeros(shape,dtype = int))
    print(np.ones(shape,dtype = int))
    
  • + 0 comments

    import numpy as np nums=tuple(map(int,input().split())) print(np.zeros(nums,dtype=int)) print(np.ones(nums,dtype=int))