w3resource
Python Exercises

Python NumPy: Create an array which looks like below array

Python NumPy: Array Object Exercise-47 with Solution

Write a Python program to create an array which looks like below array.

Sample Solution:-

Python Code:

import numpy as np
x = np.tri(4, 3, -1)
print(x)

Sample Output:

[[ 0.  0.  0.]                                                         
 [ 1.  0.  0.]                                                         
 [ 1.  1.  0.]                                                         
 [ 1.  1.  1.]]

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to create a 1-D array of 20 element spaced evenly on a log scale between 2. and 5., exclusive.
Next: Write a Python program to create an array which looks like below array.

What is the difficulty level of this exercise?