×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Range of a Matrix

Python | Range of a Matrix: Here, we are going to learn about the range of a matrix and how to find it?
Submitted by Anuj Singh, on July 11, 2020

The range of a matrix can be defined as the difference between the maximum and minimum among the elements of the matrix. In NumPy, we have provided with an inbuilt function for this operation i.e. numpy.ptp(). It returns the range of the matrix by calculating maximum-minimum.

Python | Range of a Matrix Output

Python code to find range of a matrix

# Linear Algebra Learning Sequence
# Range of a Matrix

import numpy as np

a = np.array([[14,5,3], [7,8,9], [4,2,-6]])

print('Matrix A : ', a)

# Range
print('Range of the matrix A : ', np.ptp(a))

Output:

Matrix A :  [[14  5  3]
 [ 7  8  9]
 [ 4  2 -6]]
Range of the matrix A :  20
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.