What are -1, 0, and 1 in this exercise? Why are they in this order? How can I logically understand this?


#1

Hello, here’s the link to the exercise:

https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/i-got--problems-but-a-switch-aint-one?action=resume_content_item

What are -1, 0, and 1 in this exercise? Why are they in this order? How can I logically understand this?


#2

The idea is that if x is greater than n (5) return a positive number, if less than return a negative number, if the same, return zero. This relates to sorting, though an explanation at this point might be jumping the queue since sorting is a tricky concept, to begin with and usually left until intermediate or advanced topics surface.

Something of note in signed binary numbers…

11111111111111111111111111111111  (32-bit representation of -1)
0
1