greater than and less than | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

greater than and less than

We can use equal = and not equal != but why we can't use not greater than !> and not less than !< ???

22nd Sep 2019, 2:20 AM
Din Din
Din Din - avatar
4 Answers
+ 5
Because those operators aren't defined and you can simply use the inverse or negate the final comparison. But if you insist try !(a>b) instead of (a<b). They are equal in most respects, except the former is a tiny faction less efficient.
22nd Sep 2019, 4:50 AM
Lord Krishna
Lord Krishna - avatar
+ 3
The negation of "greater than" (>) is "less than or equal to" (<=), and viceversa. The negation of "less than" (<) is "greater than or equal to" (>=), and viceversa. [Python] print(4>2) # True print(4<=2) # False print(4<2) # False print(4>=2) # True
22nd Sep 2019, 2:34 AM
Diego
Diego - avatar
+ 3
And remember "=" is the assignment operator. "==" means "equals".
22nd Sep 2019, 3:18 AM
David Ashton
David Ashton - avatar
+ 2
Not greater than or equal to is equivalent to less than. Not less than or equal to is equivalent to more than. And You want to do: if (!(f>=0))... This
22nd Sep 2019, 2:41 AM
Chirag Kumar
Chirag Kumar - avatar