We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Eye and Identity
- Discussions
Eye and Identity
Eye and Identity
Sort by
recency
|
297 Discussions
|
Please Login in order to post a comment
import numpy numpy.set_printoptions(legacy="1.13") N,M=list(map(int,input().split())) print(numpy.eye(N,M,k=0))
Your task is to print an array of size X with its main diagonal elements as 's and 's everywhere else.
Note
In order to get alignment correct, please insert the line below the numpy import.
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.
Sample Input
3 3 Sample Output
[[ 1. 0. 0.] [ 0. 1. 0.] [ 0. 0. 1.]]