Sobes.tech
Intern — Senior

Determining the median of three numbers

livecode

Task condition

Implement the function find_middle_number(), which takes three parameters in the specified order:

  • x — an integer (|x| ≤ 10³);
  • y — an integer (|y| ≤ 10³);
  • z — an integer (|z| ≤ 10³).

The function should return the number that is in the middle by value among the given x, y, z.

Constraints The function must return the median (by value) of the three input numbers.

Example 1:

print(find_middle_number(1, 2, 3))

Output: 2

Example 2:

print(find_middle_number(3, 1, 2))

Output: 2