Python Logical Operators Example

Example: 

#!/usr/bin/python

x = True
y = False
print(‘x and y is’,x and y)
print(‘x or y is’,x or y)
print(‘not x is’,not x)

Output:

x and y is False
x or y is True
not x is False

Few more example:

1.

if (five == 5) AND (two == 2):

print five, two

2. 

if not (age >= 17):

print(“Hey, you’re too young to get a driving licence!”)

3.

if not ((sword_charge >= 0.90) and (shield_energy >= 100)):

print(“Your attack has no effect, the dragon fries you to a crisp!”)

else:

print(“The dragon crumples in a heap. You rescue the gorgeous princess!”)

 

 Think about more program and share your program output as comment

 

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: