NOT

The logical_not operation takes one value and converts it into another value. If the value is 0, then output is 1, if value is greater than or equal to 1 output is 0.

Syntax:

numpy.logical_not(var1)

Where, var1is a single variable or a list/array.

Return type: Boolean value (True or False)

Example:

Python3




# importing numpy module
import numpy as np
  
# logical  not operations for boolean value
print('logical_not operation =  '
      np.logical_not(True))
  
a = 2
b = 6
print('logical_not Operation  =  '
      np.logical_not(a))
print('logical_not Operation  =  '
      np.logical_not(b))
  
  
# list 1 represents an array with integer values
list1 = [1, 2, 3, 4, 5, 0]
  
# logical operations between integer values
print('Operation in list =  '
      np.logical_not(list1))


Output:

NumPy Array – Logical Operations

Logical operations are used to find the logical relation between two arrays or lists or variables. We can perform logical operations using NumPy between two data. Below are the various logical operations we can perform on Numpy arrays:

Similar Reads

AND

The numpy module supports the logical_and operator. It is used to relate between two variables. If two variables are 0 then output is 0, if two variables are 1 then output is 1 and if one variable is 0 and another is 1 then output is 0....

OR

...

NOT

...

XOR

The NumPy module supports the logical_or operator. It is also used to relate between two variables. If two variables are 0 then output is 0, if two variables are 1 then output is 1 and if one variable is 0 and another is 1 then output is 1....