- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return the truth value of an array less than equal to another element-wise in Numpy

To return the truth value of an array less than equal to another element-wise, use the **numpy.less_equal()** method in Python Numpy. Return value is either True or False. Returns output array, element-wise comparison of x1 and x2. Typically of type bool, unless dtype=object is passed. This is a scalar if both x1 and x2 are scalars.

The condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.

## Steps

At first, import the required library −

import numpy as np

Creating two 2D numpy array using the array() method. We have inserted elements of int type −

arr1 = np.array([[49, 76, 61], [82, 69, 29]]) arr2 = np.array([[40, 60, 61], [81, 55, 32]])

Display the arrays −

print("Array 1...\n", arr1) print("\nArray 2...\n", arr2)

Get the type of the arrays −

print("\nOur Array 1 type...\n", arr1.dtype) print("\nOur Array 2 type...\n", arr2.dtype)

Get the dimensions of the Arrays −

print("\nOur Array 1 Dimensions...\n",arr1.ndim) print("\nOur Array 2 Dimensions...\n",arr2.ndim)

Get the shape of the Arrays −

print("\nOur Array 1 Shape...\n",arr1.shape) print("\nOur Array 2 Shape...\n",arr2.shape)

To return the truth value of an array less than equal to another element-wise, use the numpy.less_equal() method. Return value is either True or False −

print("\nResult...\n",np.less_equal(arr1, arr2))

## Example

import numpy as np # Creating two 2D numpy array using the array() method # We have inserted elements of int type arr1 = np.array([[49, 76, 61], [82, 69, 29]]) arr2 = np.array([[40, 60, 61], [81, 55, 32]]) # Display the arrays print("Array 1...\n", arr1) print("\nArray 2...\n", arr2) # Get the type of the arrays print("\nOur Array 1 type...\n", arr1.dtype) print("\nOur Array 2 type...\n", arr2.dtype) # Get the dimensions of the Arrays print("\nOur Array 1 Dimensions...\n",arr1.ndim) print("\nOur Array 2 Dimensions...\n",arr2.ndim) # Get the shape of the Arrays print("\nOur Array 1 Shape...\n",arr1.shape) print("\nOur Array 2 Shape...\n",arr2.shape) # To return the truth value of an array less than equal to another element-wise, use the numpy.less_equal() method in Python Numpy # Return value is either True or False print("\nResult...\n",np.less_equal(arr1, arr2))

## Output

Array 1... [[49 76 61] [82 69 29]] Array 2... [[40 60 61] [81 55 32]] Our Array 1 type... int64 Our Array 2 type... int64 Our Array 1 Dimensions... 2 Our Array 2 Dimensions... 2 Our Array 1 Shape... (2, 3) Our Array 2 Shape... (2, 3) Result... [[False False True] [False False True]]

- Related Questions & Answers
- Return the truth value of an array less than another element-wise in Numpy
- Return the truth value of an array greater than equal to another element-wise in Numpy
- Return the truth value of an array equal to another element-wise in Numpy
- Return the truth value of an array greater than another element-wise in Numpy
- Return the truth value of an array not equal to another element-wise in Numpy
- Compute the truth value of an array XOR another array element-wise in Numpy
- Compute the truth value of an array AND to another array element-wise in Numpy
- Compute the truth value of an array OR to another array element-wise in Numpy
- Compute the truth value of NOT an array element-wise in Numpy
- Compute the truth value of an array XOR another array element-wise based on conditions in Numpy
- Compute the truth value of an array AND to another array element-wise based on conditions in Numpy
- Compute the truth value of an array OR to another array element-wise based on conditions in Numpy
- Compare and return True if a Numpy array is less than equal to another
- Compute the truth value of NOT an array element-wise based on conditions in Numpy
- Compare and return True if an array is less than another array in Numpy