shape

The shape tool gives a tuple of array dimensions and can be used to change the dimensions of an array.

(a). Using shape to get array dimensions

import numpy

my__1D_array = numpy.array([1, 2, 3, 4, 5])
print my_1D_array.shape     #(5,) -> 1 row and 5 columns

my__2D_array = numpy.array([[1, 2],[3, 4],[6,5]])
print my_2D_array.shape     #(3, 2) -> 3 rows and 2 columns 

(b). Using shape to change array dimensions    

import numpy

change_array = numpy.array([1,2,3,4,5,6])
change_array.shape = (3, 2)
print change_array      

#Output
[[1 2]
[3 4]
[5 6]]

reshape

The reshape tool gives a new shape to an array without changing its data. It creates a new array and does not modify the original array itself. 

import numpy

my_array = numpy.array([1,2,3,4,5,6])
print numpy.reshape(my_array,(3,2))

#Output
[[1 2]
[3 4]
[5 6]]

Task 

You are given a space separated list of nine integers. Your task is to convert this list into a $3$X$3$ NumPy array.

Input Format

A single line of input containing $\mbox{9}$ space separated integers.

Output Format

Print the $3$X$3$ NumPy array.

Sample Input
1 2 3 4 5 6 7 8 9

Sample Output
[[1 2 3]
 [4 5 6]
 [7 8 9]]

Source: hackerrank | Difficulty: EASY


Solutions:
import numpy
a = numpy.array(input().split(), int)
a.shape = (3, 3)
print(a)


import numpy as np
v = np.array([int(i) for i in input().split()])
v.shape = (3, 3)
print(v)


import numpy

def mapl(f, x):
	return list(map(f, list(x)))
a = numpy.array(mapl(int, input().split()), int)
print(numpy.reshape(a, (3, 3)))


import numpy
arr = numpy.array([int(x) for x in input().split(' ')])
print(numpy.reshape(arr, (3, 3)))


import numpy
a = numpy.array(list(map(int, input().split())))
print(numpy.reshape(a, (3, 3)))


import numpy
i = numpy.array([int(x) for x in input().split()])
print(i.reshape(3, 3))


import numpy
print(numpy.reshape(numpy.array(list((int(x) for x in input().split()))), (3, 3)))


import numpy as np
i = np.array(str(input()).split(' '), int)
i.shape = (3, 3)
print(i)


import numpy as np
import sys
A = np.array(sys.stdin.readline().split(), int)
print(A.reshape(3, 3))


import numpy
l = input().split()
a = numpy.array(l, int)
a.shape = (3, 3)
print(a)


import numpy
arr = numpy.array(input().strip().split(), int)
arr.shape = (3, 3)
print(arr)


import numpy
n = numpy.array(list(map(int, input().split())))
n.shape = (3, 3)
print(n)


import numpy
A = list(map(int, input().split()))
print(numpy.reshape(A, (3, 3)))


import numpy
print(numpy.array([int(i) for i in input().split()], int).reshape(3, 3))


import numpy
tmp = [int(x) for x in input().strip().split()]
arr = numpy.array(tmp)
print(arr.reshape(3, 3))


import numpy
l = list(map(int, input().split()))
my_array = numpy.array(l)
print(numpy.reshape(my_array, (3, 3)))


import numpy
arr = numpy.array([int(x) for x in input().strip().split()])
arr.shape = (3, 3)
print(arr)


import numpy
a = numpy.array(list(map(int, input().strip().split())))
print(numpy.reshape(a, (3, 3)))


import numpy as np
print(np.array(list(map(int, input().strip().split(' ')))).reshape((3, 3)))


import numpy

def reshape(input):
	arr = numpy.array(input.split(' '), int)
	print(numpy.reshape(arr, (3, 3)))
reshape(input())


from numpy import array
numbers = array(list(map(int, input().split())))
numbers.shape = (3, 3)
print(numbers)


import numpy as num
print(num.reshape(num.array([int(i) for i in input().split()]), (3, 3)))


import numpy
print(numpy.reshape(numpy.array([int(x) for x in input().split()]), (3, 3)))


import numpy
x = list(map(int, input().split()))
print(numpy.reshape(numpy.array(x), (3, 3)))


import numpy
a = list(map(int, input().split()))
a = numpy.array(a)
a.shape = (3, 3)
print(a)


import numpy as np
print(np.reshape(list(map(int, input().split())), (3, 3)))


import numpy
nums = numpy.array(input().split(), int)
nums.shape = (3, 3)
print(nums)


import numpy as np
arr = np.array(input().split(), int)
arr.shape = (3, 3)
print(arr)


import numpy
a = list(map(int, input().split()))
print(numpy.reshape(a, (3, 3)))


import numpy
inputList = [int(x) for x in input().split()]
numpyArr = numpy.array(inputList)
print(numpy.reshape(numpyArr, (3, 3)))


import numpy
n = [int(n) for n in input().split()]
arr = numpy.array(n, dtype=int)
print(arr.reshape(3, 3))


import numpy as np
arin = input().split(' ')
ar = [int(x) for x in arin]
print(np.reshape(ar, (3, 3)))


import numpy
print(numpy.array(input().split(' '), int).reshape(3, 3))


import numpy
print(numpy.array([int(x) for x in input().split()]).reshape(3, 3))


import numpy
a = input()
arr = list(map(int, a.split()))
v = numpy.reshape(arr, (3, 3))
print(v)


import numpy
print(numpy.reshape(numpy.array(input().split(), int), (3, 3)))


import numpy as np
print(np.fromstring(input(), dtype=int, sep=' ').reshape(3, 3))


import numpy
l = list(map(int, input().strip().split()))
assert len(l) == 9
print(numpy.array(l).reshape(3, 3))


import numpy
a = numpy.array(list(map(int, input().split())), int)
print(a.reshape(3, 3))


import numpy
ar = input().split()
ar = numpy.array(ar, int)
ar.shape = (3, 3)
print(ar)


import numpy
n = numpy.array([int(x) for x in input().split()])
print(numpy.reshape(n, (3, 3)))


import numpy
arr = numpy.array(list(map(int, input().split())))
arr.shape = (3, 3)
print(arr)


import numpy as np
ints = [int(x) for x in input().split()]
arr = np.array(ints)
print(np.reshape(arr, (3, 3)))


import numpy
a = numpy.array(list(map(int, input().split())))
a.shape = (3, 3)
print(a)


import numpy
my_arr = numpy.array(input().split(), int)
print(numpy.reshape(my_arr, (3, 3)))


import numpy as np
import sys
N = [int(x) for x in input().split()]
my_array = np.array(N)
print(np.reshape(my_array, (3, 3)))


import numpy
a = numpy.array(input().split(), int)
a = numpy.reshape(a, (3, 3))
print(a)


import numpy
print(numpy.reshape(numpy.array(list(map(int, input().strip().split()))), (3, 3)))


import numpy
numbers = list(map(int, input().split(' ')))
num_array = numpy.array(numbers)
num_array.shape = (3, 3)
print(num_array)


import numpy
arr = numpy.array([int(a) for a in input().split(' ')])
print(numpy.reshape(arr, (3, 3)))


import numpy as np
a = [int(i) for i in input().split()]
b = np.array(a).reshape(3, 3)
print(b)


import numpy
a = numpy.array(list(map(int, input().split(' '))))
print(a.reshape(3, 3))


import numpy
print(numpy.array(list(map(int, input().strip().split()))).reshape(3, 3))


import numpy
a = input().split()
np = numpy.array(a, dtype=int)
np.shape = (3, 3)
print(np)


import numpy
input_array = numpy.array(input().split(), int)
reshaped_input_array = numpy.reshape(input_array, (3, 3))
print(reshaped_input_array)


import numpy
print(numpy.reshape(numpy.array(input().split(' '), int), (3, 3)))


import numpy
print(numpy.reshape(numpy.array(list(map(int, input().split()))), (3, 3)))


import numpy
numarr = list(map(int, input().split()))
my_array = numpy.array(numarr)
print(numpy.reshape(my_array, (3, 3)))


import numpy
A = numpy.array(input().strip().split(), int)
print(numpy.reshape(A, (3, 3)))


import numpy
ar = list(map(int, input().split()))
np_ar = numpy.array(ar)
print(numpy.reshape(np_ar, (3, 3)))


import numpy as np
x = input()
y = x.split(' ')
a = list(map(int, y))
a = np.array(a)
a = a.reshape(3, 3)
print(a)


import numpy
arr = numpy.array(input().split(), int)
arr.shape = (3, 3)
print(arr)


import numpy as np
raw = input()
numbers = list(map(int, raw.split(' ')))
x = np.reshape(np.array(numbers), (3, 3))
print(x)


import numpy
l = list(map(int, input().split()))
print(numpy.reshape(l, (3, 3)))


import numpy
ns = numpy.array(list(map(int, input().split())))
ns.shape = (3, 3)
print(ns)


import numpy
my_array = numpy.array(list(map(int, input().split())))
print(numpy.reshape(my_array, (3, 3)))


import numpy
A = numpy.array([int(x) for x in input().split()])
A.shape = (3, 3)
print(A)


import numpy
N = [i for i in map(int, input().split())]
my_array = numpy.array(N)
print(numpy.reshape(my_array, (3, 3)))


import numpy as np
s = input()
a = s.split()
a = list(map(int, a))
npa = np.array(a)
npa = np.reshape(npa, (3, 3))
print(npa)


import numpy
a = numpy.array(input().split(), int)
print(numpy.reshape(a, (3, 3)))


import numpy
l = list(map(int, input().split()))
a = numpy.array(l)
a2 = numpy.reshape(a, (3, 3))
print(a2)


import numpy as np

def main():
	a = np.array(input().split(), int)
	a.shape = (3, 3)
	print(a)
main()


import numpy
N = list(map(int, input().split()))
my_lis = numpy.array(N)
print(numpy.reshape(my_lis, (3, 3)))


import numpy
a = numpy.array([x for x in input().split()], int)
print(numpy.reshape(a, (3, 3)))


import numpy
n = [int(x) for x in input().split()]
print(numpy.reshape(numpy.array(n), (3, 3)))


import numpy
print(numpy.reshape(numpy.array(list(input().split()), int), (3, 3)))


import numpy
listy = list(map(int, input().split(' ')))
my_array = numpy.array(listy)
my_array.shape = (3, 3)
print(my_array)