官术网_书友最值得收藏!

Rich comparison operators

We can also compare the order of quantities using the rich comparison operators. Use < to determine if the first argument is less than the second:

>>> g < 30
True

Likewise, use > to determine if the first is greater than the second:

>>> g > 30
False

You can test less-than or equal-to with <=:

>>> g <= 20
True

We can use the greater-than or equal-to with >= ,shown as follows:

>>> g >= 20
True

If you have experience with relational operators from other languages, then Python's operators are probably not surprising at all. Just remember that these operators are comparing equivalence, not identity, a distinction we'll cover in detail in coming chapters.

主站蜘蛛池模板: 金沙县| 外汇| 二手房| 金湖县| 北宁市| 宁南县| 昆山市| 广灵县| 苏州市| 襄樊市| 五华县| 布尔津县| 惠来县| 壶关县| 延边| 台安县| 威海市| 安福县| 建宁县| 前郭尔| 和政县| 南华县| 玛沁县| 大悟县| 尚志市| 乌拉特前旗| 新丰县| 阳高县| 南漳县| 呼玛县| 宜都市| 股票| 通化市| 进贤县| 宁安市| 富顺县| 唐河县| 石渠县| 鹿泉市| 新营市| 建宁县|