NumPy. Logical_ or() in Python
Truth values between x1 and x2 elementwise are computed using the NumPy. Logical or() technique. The logical OR function returns true when at least one input is true. It is denoted mathematically by the letter v. A truth table for the OR operation between p, and q is provided here.
Get back value:
When both x1 and x2 are boolean values, this function returns a single boolean value. It returns a broadcasted boolean Ndarray when both x1 and x2 are boolean Ndarrays.
In the code snippet, lines 4, 6, and 11 will be used to assess the logical OR between two scalar values, two boolean arrays, and two logical conditions.
x1 v x2 between boolean values: T x1 v x2 between boolean arrays: [ T T T F T ] x1 v x2 between conditions: [ T F F F T T T ]
Code 1: Active
Output Array : [ T T T T]
Code 2: If the input arrays have different forms, the Value Error
Value Error: operands could not be broadcast together with shapes (4,) (5,)
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week