公告
财富商城
积分规则
提问
发文
2019-01-27 04:56发布
够拽才男人
How do two or more relational operators in a single sentence work? For example:
5 < 5 <= 3 > 10
https://docs.python.org/2/reference/expressions.html#not-in
It's evaluated in order, so your expression expands to
5 < 5 and 5 <= 3 and 3 > 10
which evaluates to False
False
Python supports double-ended comparisons. For example,
3 < x <= 7
is a check for 3 < x and x <= 7 (with x being evaluated just once).
3 < x
x <= 7
x
By extension,
means (5 < 5) and (5 <= 3) and (3 > 10), all of which are False, so the whole expression evaluates to False.
(5 < 5)
(5 <= 3)
(3 > 10)
最多设置5个标签!
https://docs.python.org/2/reference/expressions.html#not-in
It's evaluated in order, so your expression expands to
which evaluates to
False
Python supports double-ended comparisons. For example,
is a check for
3 < x
andx <= 7
(withx
being evaluated just once).By extension,
means
(5 < 5)
and(5 <= 3)
and(3 > 10)
, all of which areFalse
, so the whole expression evaluates toFalse
.