How come the comparison => can compare To all numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How come the comparison => can compare To all numbers

>>> 7 <= 8 True >>> 9 >= 9.0 True

4th Nov 2018, 8:17 PM
Carson
1 Answer
+ 4
<= means less than or equal to, you get True for the 7 <= 8 expression because 7 is less than 8. >= means greater than or equal to, so you get True for the 9 >= 9.0 expression, because 9 (int) is considered equal to 9.0 (float). If you compared 9 >= 9.01 you will get False as a result. Hth, cmiiw
7th Nov 2018, 5:45 PM
Ipang