Practice · Python

Practice Multiple Returns & Scope

Return several values as a tuple, unpack them at the call site, and reason about local vs global scope.

Multiple Returns & Scopewarming python…

Space Stats Analyzer

Write a function analyze_orbit(values) that receives a list of numbers representing distances of satellites. It must return a tuple (min_val, max_val, quotient, remainder) where:

  • min_val is the smallest number in the list.
  • max_val is the largest number in the list.
  • quotient and remainder are the result of divmod(sum(values), len(values)). If the list is empty, return (None, None, 0, 0). Do not modify any variables outside the function – any assignment inside should be local.

Examples

analyze_orbit([3, 1, 4, 2])  # → (1, 4, 2, 2) because sum=10, len=4, divmod→(2,2)
analyze_orbit([])           # → (None, None, 0, 0)
Press Run to see output, or Check to grade against the tests.

Want a whole course built around multiple returns & scope?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.