Problem 139232 · easy · Level 01 Prerequisites & Setup

Smallest and Largest

functions · parameters · tuples

Write a function min_and_max(a, b, c) that takes three integers and returns two values: the smallest of the three, followed by the largest.

In Python a function can return several values at once by separating them with a comma: return x, y. The result is a tuple, which prints as (x, y).

Examples

Input:  a = 3, b = 1, c = 2
Output: (1, 3)
Input:  a = 5, b = 5, c = 5
Output: (5, 5)
Explanation: When all three are equal, the smallest and the largest are the same.

Constraints

  • -1000 <= a, b, c <= 1000
  • Return the smallest value first, then the largest.

Goals

  • Write a function that takes several parameters
  • Return two values at once as a tuple
  • Compare three numbers with conditionals
Starting Python…