xxxxxxxxxx
# Compare the first items, it goes to the next if only both are the same
print((0, 1, 2) < (5, 1, 0)) # Output: True
print((0, 1, 20000) < (1, 0)) # Output: True
print(('John', 'Sally') < ('Adams', 'Sam')) # Output: False
xxxxxxxxxx
'''In python, tuples are compared item by item, by order of the index
0 with 0, 1 with 1...
True or False is returned for the first couple of different items
Here are some examples'''
>>> (2, 4) < (1, 5)
False # Because 2 > 1
>>> (2, 4) < (2, 5)
True # Because 2 = 2 and 4 < 5
'''Length does not really matters'''
>>> (2, 4, 120) < (2, 5, 0)
True # because 2 = 2, 4 < 5, 120 and 0 are not considered
>>> (2, 4, 120) < (2, 5)
True
'''In case of overflow, False is returned'''
>>> (2, 4, 5) < (2, 4)
False
xxxxxxxxxx
#----docs.python.org----
#For two collections to compare equal, they must be of the same type,
#have the same length, and each pair of corresponding elements must
#compare equal (for example, [1,2] == (1,2) is false because the type is not
#the same).
#Collections that support order comparison are ordered the same as their
#first unequal elements (for example, [1,2,x] <= [1,2,y] has the same value
#as x <= y). If a corresponding element does not exist,
#the shorter collection is ordered first (for example, [1,2] < [1,2,3] is true).
#----docs.python.org----
print( (10, 20, 5) > (10, 20, 2) )
#is true, because indexes 0 and 1 are the same whereas index 2 is different
#so it's evaluated