Created
October 30, 2021 10:21
-
-
Save naemazam/7ad00f690f005c1aba6f5aed22ae0bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
example | |
Enter your value:5 | |
[[1. 0. 0. 0. 0.] | |
[0. 2. 0. 0. 0.] | |
[0. 0. 3. 0. 0.] | |
[0. 0. 0. 4. 0.] | |
[0. 0. 0. 0. 5.]] ''' | |
import numpy as np | |
input_val = int(input('Enter your value:')) | |
x = np.zeros((input_val, input_val)) | |
np.fill_diagonal(x, range(1,input_val+1)) | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment