numpy.tri() in Python Last Updated : 09 Mar, 2022 Comments Improve Suggest changes Like Article Like Report 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. Parameters : 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. Python # Python Program illustrating # numpy.tri method import numpy as geek print("tri with k = 1 : \n",geek.tri(2, 3, 1, dtype = float), "\n") print("tri with main diagonal : \n",geek.tri(3, 5, 0), "\n") print("tri with k = -1 : \n",geek.tri(3, 5, -1), "\n") Output : 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.]] References : https://docs.scipy.org/doc/numpy/reference/generated/numpy.tri.html Note : These NumPy-Python programs won't run on online IDE's, so run them on your systems to explore them . Comment More infoAdvertise with us Next Article numpy.tri() in Python M Mohit Gupta_OMG Improve Article Tags : Misc Python Python-numpy Python numpy-arrayCreation Practice Tags : Miscpython Similar Reads numpy.tril() in Python numpy.tril(a, k=0) : Returns copy of array with lower part of the triangle w.r.t k Parameters : a : input array k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : Lower triangle of a, having same shape and data-type as a. Python 1 min read numpy.triu() in Python numpy.triu(a, k = 0) : Returns copy of array with upper part of the triangle w.r.t k Parameters : a : input array k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : Upper triangle of a, having same shape and data-type as a. Pytho 1 min read numpy.tan() in Python numpy.tan(array[, out]) = ufunc 'tan') : This mathematical function helps user to calculate trigonometric tangent for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [optional]shape same as array. 2pi Radians = 360 degrees tan(x) = sin(x) / cos(x) Ret 2 min read numpy.sin() in Python numpy.sin(x[, out]) = ufunc 'sin') : This mathematical function helps user to calculate trigonometric sine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. 2pi Radians = 36o degrees Return : An array with trigonometric sine of x for all x i.e. array elem 1 min read numpy.sinc() in Python numpy.sinc(array) : This mathematical function helps user to calculate sinc function for all x(being the array elements). Parameters : array : [array_like] elements are in radians. 2pi Radians = 36o degrees Return : An array with sinc value of x for all x i.e. array elements. Code #1 : Working Pytho 1 min read numpy.sinh() in Python The numpy.sinh() is a mathematical function that helps user to calculate hyperbolic sine for all x(being the array elements). Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) or -1j * np.sin(1j*x). Syntax: numpy.sinh(x[, out]) = ufunc 'sin') Parameters : array : [array_like] elements are in radians. 2pi 2 min read numpy.tanh() in Python The numpy.tanh()is a mathematical function that helps user to calculate hyperbolic tangent for all x(being the array elements). Equivalent to np.sinh(x) / np.cosh(x) or -1j * np.tan(1j*x). Syntax : numpy.tanh(x[, out]) = ufunc 'tanh') Parameters : array : [array_like] elements are in radians. 2pi Ra 2 min read Python | Numpy np.triu_indices With the help of np.triu_indices() method, we can get the indices for the upper triangle of an [n, m] array by using np.triu_indices() method. Syntax : np.triu_indices(n, m) Return : Return the indices for the upper triangle. Example #1 : In this example we can see that by using np.triu_indices() me 1 min read numpy.reciprocal() in Python The numpy.reciprocal() is a mathematical function that is used to calculate reciprocal of all the elements in the input array. Syntax :numpy.reciprocal(x, /, out=None, *, where=True) Parameters : x[array_like]: Input array or object whose elements needed to test. out [ndarray, optional]: A location 2 min read numpy.cos() in Python numpy.cos(x[, out]) = ufunc 'cos') : This mathematical function helps user to calculate trigonometric cosine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. 2pi Radians = 360 degrees Return : An array with trigonometric cosine of x for all x i.e. array 2 min read Like