Shape and Reshape

Sort by

recency

|

374 Discussions

|

  • + 0 comments

    def reshape(arr): arr1 = numpy.array(arr) res = numpy.reshape(arr1,(3,3)) return res

    arr = list(map(int,input().split())) print(reshape(arr))

  • + 0 comments

    import numpy import sys

    chars = sys.stdin.read().split() arr = numpy.array([int(char) for char in chars]) arr.shape = (3,3) print(arr)

  • + 0 comments

    import numpy

    arr=list(map(int,input().split()))

    change_array=numpy.array(arr) change_array=change_array.reshape(3,3) print(change_array)

  • + 0 comments

    With the help of regEx :

    import sys, re, numpy
    
    entry = sys.stdin.read().splitlines()
    
    for line in entry:
        print(numpy.array([int(i) for i in re.findall(r"\d", line)]).reshape(3, 3))
    
  • + 0 comments

    import numpy as np """ list() # use to create list map # use to apply a integer function to all iterables items int # the fuction convert input into integer like number np.array() ##### to convert list into array """ array=np.array(list(map(int,input().split()))).reshape(3,3) print(array)