Articles → Python → Logical operators in python

Logical operators in python

Logical operators

And operator

Condition 1 and condition 2

age = 19
nationality = "indian"

# If you are above 18 years of age and your nationality is indian then you are eligible to vote.

if age > 18 and nationality == "indian":
        print("You are eligble to vote")

Click to Enlarge

Or operator

Condition 1 or condition 2

isAmazonEmployee = False
isPrimeMembershipHolder  = True

# If you are an amazon employee or have amazon prime membership then you can watch that movie

if isAmazonEmployee ==True or isPrimeMembershipHolder == True:
        print("You are eligible to watch the movie")

Click to Enlarge

Not operator

Click to Enlarge

Posted By  -  Karan Gupta
Posted On  -  Sunday, February 17, 2019


Your Email Id  
Query/FeedbackCharacters remaining 250