numpy.logical_not() in Python Last Updated : 29 Nov, 2018 Comments Improve Suggest changes Like Article Like Report numpy.logical_not(arr, out=None, where = True, casting = 'same_kind', order = 'K', dtype = None, ufunc 'logical_not') : This is a logical function that computes the truth value of NOT arr element-wise. Parameters : arr1 : [array_like]Input array. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions(ufunc) at that position, False value means to leave the value in the output alone. Return : An array with Boolean results of NOT arr (element-wise). Code 1 : Working Python # Python program explaining # logical_not() function import numpy as np # input arr1 = [1, 3, False, 4] arr2 = [3, 0, True, False] # output out_arr1 = np.logical_not(arr1) out_arr2 = np.logical_not(arr2) print ("Output Array 1 : ", out_arr1) print ("Output Array 2 : ", out_arr2) Output : Output Array 1 : [False False True False] Output Array 2 : [False True False True] Code 2 : Can check condition Python # Python program explaining # logical_not() function import numpy as np # input arr1 = np.arange(8) # Applying Condition print ("Output : \n", arr1/4) # output out_arr1 = np.logical_not(arr1/4 == 0) print ("\n Boolean Output : \n", out_arr1) Output : Output : [ 0. 0.25 0.5 0.75 1. 1.25 1.5 1.75] Boolean Output : [False True True True True True True True] References : https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.logical_not.html#numpy.logical_not . Comment More infoAdvertise with us Next Article numpy.logical_not() in Python mohit gupta_omg :) Follow Improve Article Tags : Python Python-numpy Python numpy-Logic Functions Practice Tags : python Similar Reads numpy.logical_or() in Python numpy.logical_or(arr1, arr2, out=None, where = True, casting = 'same_kind', order = 'K', dtype = None, ufunc 'logical_or') : This is a logical function and it helps user to find out the truth value of arr1 OR arr2 element-wise. Both the arrays must be of same shape. Parameters : arr1 : [array_like]I 2 min read numpy.logical_and() in Python numpy.logical_and(arr1, arr2, out=None, where = True, casting = 'same_kind', order = 'K', dtype = None, ufunc 'logical_and') : This is a logical function and it helps user to find out the truth value of arr1 AND arr2 element-wise. Both the arrays must be of same shape. Parameters : arr1 : [array_lik 2 min read numpy.isnan() in Python The numpy.isnan() function tests element-wise whether it is NaN or not and returns the result as a boolean array. Syntax : numpy.isnan(array [, out]) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array placed wit 2 min read numpy.isneginf() in Python The numpy.isneginf() function tests element-wise whether it is negative infinity or not, and returns the result as a boolean array. Syntax :  numpy.isneginf(array, y = None) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boole 2 min read numpy.isposinf() in Python The numpy.isposinf() function tests element-wise whether it is positive infinity or not and returns the result as a boolean array. Syntax : numpy.isposinf(array, y = None) Parameters:  array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boolea 2 min read numpy.any() in Python The numpy.any() function tests whether any array elements along the mentioned axis evaluate to True. Syntax : numpy.any(a, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c) Parameters : array :[array_like]Input array or object whose elements, we need to test. axis : 3 min read numpy.all() in Python The numpy.all() function tests whether all array elements along the mentioned axis evaluate to True. Syntax: numpy.all(array, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c) Parameters : array :[array_like]Input array or object whose elements, we need to test. axis 3 min read numpy.not_equal() in Python The numpy.not_equal() checks whether two element are unequal or not. Syntax : numpy.not_equal(x1, x2[, out])Parameters : x1, x2 : [array_like]Input Array whose elements we want to checkout : [ndarray, optional]Output array that returns True/False. A placeholder the same shape as x1 to store the resu 2 min read Python | numpy.isnat() method With the help of numpy.isnat() method, we can get the boolean value as true if date defined in a np.datetime64() method is not a time by using numpy.isnat() method. Syntax : numpy.isnat() Return : Return the boolean value if time is not found. Example #1 : In this example we can see that by using nu 1 min read Logical Operations on String in Python For strings in python, boolean operators (and, or, not) work. Let us consider the two strings namely str1 and str2 and try boolean operators on them: Python str1 = '' str2 = 'geeks' # repr is used to print the string along with the quotes # Returns str1 print(repr(str1 and str2)) # Returns str1 prin 2 min read Like