numpy.tri(R, C = None, k = 0, dtype = ‘float’) : Creates an array with 1’s at and below the given diagonal(about k) and 0’s elsewhere.
R : Number of rows C : [optional] Number of columns; By default R = C k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. dtype : [optional, float(byDefault)] Data type of returned array.
tri with k = 1 : [[ 1. 1. 0.] [ 1. 1. 1.]] tri with main diagonal : [[ 1. 0. 0. 0. 0.] [ 1. 1. 0. 0. 0.] [ 1. 1. 1. 0. 0.]] tri with k = -1 : [[ 0. 0. 0. 0. 0.] [ 1. 0. 0. 0. 0.] [ 1. 1. 0. 0. 0.]]
These NumPy-Python programs won’t run on onlineID, so run them on your systems to explore them
This article is contributed by Mohit Gupta_OMG 😀. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python - Read blob object in python using wand library
- MySQL-Connector-Python module in Python
- twitter-text-python (ttp) module - Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Convert list to Python array
- Python | Index of Non-Zero elements in Python list
- Python | PRAW - Python Reddit API Wrapper
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- Python Try Except
- set add() in python
- Python Set | pop()
- C Vs Python