[Tutor] Sequence Comparison

Hameed Khan hameedkhaan at yahoo.com
Mon Jan 12 12:06:45 EST 2004


Hi,
  i was reading the Sequence comparison section of
python documentation. but i really didnot understand
from it. if anyne of you can explain it to me then it
will be very kind of you. the below is the examples
with the questions i have in mind.

>>> (1, 2, 3)              < (1, 2, 4)
True
# Q.1 why it returns True when 1 is not lower then 1
and 2 is not lower then 2. only 3 is lower then 4

>>> [1, 2, 3]              < [1, 2, 4]
True
# the above question (Q.1) similarly apllies to this
comparison result too


>>> 'ABC' < 'C' < 'Pascal' < 'Python'
True
# Q.2 what is the procedure of comparison in different
size of sequences because 'ABC' is greater then 'C' in
size and 'Pascal' is greater then 'C' but equal to
'Python' in size

>>> (1, 2, 3, 4)           < (1, 2, 4)
True
# the above 2 question (Q.1 and Q.2) applies to this
comparison because this tuples have different sizes

>>> (1, 2)                 < (1, 2, -1)
True
# i totally didnot understand it

>>> (1, 2, 3)             == (1.0, 2.0, 3.0)
True
# i understand it a little bit that the elements of
second tuple converted to the type of elements of
first tuple and then compared but what if we compare
(1,"string",3) == (1.0,2.0,3.0)

>>> (1, 2, ('aa', 'ab'))   < (1, 2, ('abc', 'a'), 4)
True
# may be i will understand it if someone explains me
the above comparisons

Hameed khan

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus



More information about the Tutor mailing list