Exercise 1 solution (Python) def back(bearing): return (bearing + 180) % 360 for b in (45, 124, 300, 180, 0, 359): print(b, "->", back(b)) Output: 45 -> 225 124 -> 304 300 -> 120 180 -> 0 0 -> 180 359 -> 179 Why modulo works: adding 180 always turns the bearing round. If the result is 360 or more, the % 360 wraps it back into the range 0 to 359 (the same as subtracting 360), and if it is already under 360 the % 360 leaves it unchanged. So one expression covers both "add 180" and "subtract 180".