Input Format
A single line containing the space separated values of  and .
 denotes the rows.
 denotes the columns.
Output Format
Print the desired X array.

hackerrank eye and identity problem solution in python programming

Problem solution in Python 3 programming language.

import numpy
N, M = map(int, input().split())
print(numpy.eye(N, M, k = 0))

Second solution

import numpy
print(str(numpy.eye(*map(int,input().split())))
.replace('1',' 1').replace('0',' 0'))

Problem solution in Python 4 programming language.

import numpy
N, M = map(int, raw_input().split())
print numpy.eye(N, M, k = 0)