In this Eye and Identity problem, Your task is to print an array of size N X M with its main diagonal elements as 1’s and 0’s everywhere else.
Problem solution in Python 2 programming.
import numpy N, M = map(int, raw_input().split()) print numpy.eye(N,M)
Problem solution in Python 3 programming.
import numpy print(str(numpy.eye(*map(int,input().split()))).replace('1',' 1').replace('0',' 0'))
Problem solution in pypy programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy n, m = map(int, raw_input().strip().split()) print numpy.eye(n, m)
Problem solution in pypy3 programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy as np N,M=list(map(int,input().split())) print(np.eye(N,M))