Zeros and Ones

Sort by

recency

|

317 Discussions

|

  • + 0 comments

    Sample code is wrong :P written for python 2 instead of python 3, and either a different version of numpy than what is in the run environment, or a typo for numpy.int

    in any case:

    import numpy
    shape = tuple(int(i) for i in input().split())
    print(np.zeros(shape, int))
    print(np.ones(shape, int))
    

    this comment editor is also broken :P (no scrolling when the input exceeds the text box size)

  • + 0 comments

    My compact solution…

    import numpy as np
    
    d = list(map(int, input().split()))
    print(np.zeros(d, int), np.ones(d, int), sep='\n')
    
  • + 0 comments

    import numpy as np x = list(map(int,input().strip().split())) arr1 = np.ones(x,dtype=int) arr2 = np.zeros(x,dtype=int) print(arr2, arr1, sep='\n')

  • + 0 comments

    It's awesome to see learners share tips and insights—makes understanding concepts like shape, dtype, and multidimensional arrays so much easier! 11x play

  • + 0 comments

    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)