Wednesday, November 18, 2009

Python - boolean and, or, and not

# python includes the basic and, 
# or, and not boolean operations 
 
a = 10
b = 20
c = 30
 
if a>9 and b+1==21 and c==a+b:
    print "boolean 'and' example equates true" 
 
if a==9 or b<10 or c<100:
    print "only one of these expressions needs to be true" 
 
if not a+b==31:
    print "if this is not true" 
    
 

No comments:

Post a Comment