w3resource logo

:

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:

Improve this sample solution and post your code through Disqus