NumPy | Python Methods and Functions

** **

** numpy.tri (R, C = No, k = 0, dtype = & # 39; float & # 39;): ** Creates an array with 1 at and below the given diagonal (about k) and 0 elsewhere.

** Parameters :**

R:Number of rowsC:[optional] Number of columns; By default R = Ck:[int, optional, 0 by default] Diagonal we require; k & gt; 0 means diagonal above main diagonal or vice versa.dtype:[optional, float (byDefault)] Data type of returned array.

` `

` ` ` # Python program illustrating `

` # numpy.tri method `

` import `

` numpy as geek `

` print `

` (`

` "tri with k = 1:" `

`, geek.tri (`

` 2 `

`, `

` 3 `

`, `

` 1 `

`, dtype `

` = `

` float `

`), `

` "" `

`) `

` print `

` (`

`" tri with main diagonal: "`

`, geek.tri (`

` 3 `

`, `

` 5 `

`, `

` 0 `

`), `

` "" `

`) `

` print `

` (`

` "tri with k = -1:" `

`, geek.tri (`

` 3 `

`, `

` 5 `

`, `

` - `

` 1 `

`), `

` "" `

`) `

** Exit: **

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.]]

Links:

https: / /docs.scipy.org/doc/numpy/reference/generated/numpy.tri.html

Notes:

These NumPy-Python programs will not work with onlineID, so run them on your systems to examine them

,

This article is provided byMohit Gupta_OMG

Learning Correct Cryptography by Example. The interconnected world of the current era has drastically changed everything, including banking, entertainment, and even statecraft. Despite difference...

23/09/2020

Python Crash Course is the world's best-selling guide to the Python programming language. This quick and in-depth introduction to Python programming will get you started writing programs, solving prob...

11/08/2021

Efficiently perform data collection, wrangling, analysis, and visualization using Python. Recent advancements in computing and artificial intelligence have completely changed the way we understand ...

23/09/2020

This is the first book on synthetic data for deep learning, and its extensive coverage could make this book the standard benchmark for synthetic data for years to come. The book can also serve as an i...

28/08/2021

X
# Submit new EBook