How do I determine whether a given integer is between two other integers (e.g. greater than/equal to 10000 and less than/equal to 30000)?
10000
30000
I\
Suppose there are 3 non-negative integers: a, b, and c. Mathematically speaking, if we want to determine if c is between a and b, inclusively, one can use this formula:
a
b
c
(c - a) * (b - c) >= 0
or in Python:
> print((c - a) * (b - c) >= 0) True