- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Operators / of Python Logical Operators Basic Examples
# Logical AND operator print('ogical AND operator'.center(50,'-')) fruits = 'apples' vegitables = 'onions' condition_1 = fruits == 'apples' condition_2 = vegitables == 'onions' print('condition_1 : ',condition_1) print('condition_2 : ',condition_2) if condition_1 and condition_2: print("Two conditions are satisfied") else: print("Two conditions must and should True.") # Single Statement if fruits == 'apples' and vegitables == 'onions': print("Two conditions are satisfied") else: print("Two conditions must and should True.") # Logical OR operator. print('Logical OR operator.'.center(50,'-')) fruits = 'apples' vegitables = 'onions' condition_1 = fruits =='applesk' condition_2 = vegitables =='onionsk' print('condition_1 : ',condition_1) print('condition_2 : ',condition_2) if condition_1 or condition_2: print("One or More conditions are satisfied") else: print("At least one condition should be true") # Single Statement if fruits == 'applesl' or vegitables == 'onionsk': print("Two conditions are satisfied") else: print("At least one condition should be True.") # Logical NOT operator print('Logical NOT operator'.center(50,'-')) fruits = 'applesp' condition = fruits =='apples' print(condition) if not condition: print("condtion is false ,but we make it true.") else: print("Condition is true,but we make it false.")