Logical Operators in Python - MyPythonGuru

Jobs Search Portal and Learning point for Python,Data Science,AI,ML, Cloud and latest technologies.

Follow us on Facebook

Post Top Ad

Your Ad Spot

Tuesday, July 16, 2019

Logical Operators in Python


Logical operators



Logical operators are used check more than one condition at a time.


Logical operators allow you to combine or modify conditions.


Below are Types of logical operator

And—


It returns as Tue if both conditions are true else its returns false value.

Or—


It returns true if any of both condition is true, and returns false if both conditions are false.


Not—reverse the result, returns False if the results are true.


# Condition statement example

avengers_release_year = 2018

if(avengers_release_year > 2018) and (avengers_release_year < 2020):
    print ("Avenger  was released in between 2018 and 2020")
   
print("")
print("carry on..")

Reference : Python Doc

No comments:

Post Top Ad

Your Ad Spot