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")




Picture showing the output of the And operator in python

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")




Picture showing the output of the Or operator in python

Click to Enlarge


Not operator






Picture showing the output of the Not operator in python

Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250