Python Tutorial

Saturday, July 13, 2013

Python chain comparison


x = 10

print '5<x<9',5<x<9
print '5<x<11',5<x<11
print '5<x<11<10*x<101',5<x<11<10*x<101
print '10==x<90==9*x',10==x<90==9*x

Output:
5<x<9 False
5<x<11 True
5<x<11<10*x<101 True
10==x<90==9*x True

0 comments:

Post a Comment