PRO
Michael
asked

Expert
Abhay Jajodia answered
Hi Michael,
Yes, they are! In Python, and, or, and not are called logical operators. They're used to work with boolean values — True and False — and control the flow of your program based on conditions.
Here’s what each one does:
and→ returnsTrueonly if both conditions are trueor→ returnsTrueif at least one condition is truenot→ flips the value:not TruebecomesFalse, and vice versa
Example:
age = 23
is_member = True
if age >= 18 and is_member:
print("You can buy the offer!")
else:
print("Sorry, offer not available.")
So yes — these are definitely operators, just like + or ==, but used for logic.
If you have more questions, I am here to help.
Python
This question was asked as part of the Getting started with Python course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer