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: