Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Python for Basic Data Analysis: 1.10 Logical operators

Get started on your learning journey towards data science using Python. Equip yourself with practical skills in Python programming for the purpose of basic data manipulation and analysis.

Logical operators 

Logical operators 

We use these operators to evaluate a statement to return either a  True  or a  False 

Operator Syntax Description Example
and x and y This returns  True  if both x and y are true

x = 10
x > 5 and x < 15

or x or y This returns  True  if either x or y are true x = 10
x > 5 or x < 2
not not x Reverses a result, so if something is  True ,
not turns it  False 
x = 10
not(x > 5 and x < 15)



Use the operators to evaluate whether these statements are  True  or   False .

Qn Equation True or False?
1 x = 200
print(x > 4 or x < 300)
 True  or   False 
2 3 != 4 and 3 < 4  True  or   False 
3 x = 200
print(not(x > 4 or x < 300))
 True  or   False