Recent Posts

Logical Operators


Logical operators work when we got multiple conditions (And  and Or)


There are following logical operators supported by Python language. Assume variable a holds 10 and variable b holds 20 then −
OperatorDescriptionExample
and Logical ANDIf both the operands are true then condition becomes true.(a and b) is true.
or Logical ORIf any of the two operands are non-zero then condition becomes true.(a or b) is true.
not Logical NOTUsed to reverse the logical state of its operand.Not(a and b) is false.

In the next example, there is an application to buy a house, the person needs a high income AND good credit. If both conditions are true, the applicant is eligible for a loan


Both conditions need to be True..
now check what happens if either of them is false



We can also apply with the OR statement, it means that either way, in ONE of them is true, it's approved


AND: Both True
OR: Ar least one of them must be true
AND NOT


We will ad the statement has a bankrupt record



When you use this condition one has to be True and the other one has to be False




Logical Operators Logical Operators Reviewed by ohhhvictor on May 05, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.