0% found this document useful (0 votes)
44 views1 page

Python Logical Operators Overview

logical operators

Uploaded by

afshu.serein
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Python Logical Operators Overview

logical operators

Uploaded by

afshu.serein
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Logical Operators Recap

1. OR Operator Table
Expression Result Explanation
True or 10 True Returns first truthy value
False or 10 10 False is falsy → returns
second value
10 or False 10 10 is truthy → returns first
value
0 or 15 15 0 is falsy → returns second
value
10 or 15 10 10 is truthy → returns first
value
15 or 10 15 15 is truthy → returns first
value
"" or "Hello" "Hello" Empty string is falsy →
returns second value
"Hi" or "Hello" "Hi" First non-empty string is
truthy → returns first
10 or True 10 10 is truthy → returns first
value
0 or True True 0 is falsy → returns second
value
False or True True False is falsy → returns
second value

2. AND Operator Table


Expression Result Explanation
True and 10 10 True is truthy → returns
second value
10 and True True 10 is truthy → returns
second value
False and 10 False False is falsy → returns first
value
0 and 10 0 0 is falsy → returns first
value
False and True False False is falsy → returns first
value
10 and False False 10 is truthy → returns
second value

Python Logic Rules Recap


• A or B → If A is truth, returns A. If A is fals, returns B.
• A and B → If A is false, returns A. If A is truth, returns B.

You might also like