25 XP

7. Largest of three

Beginner conditions

Write a function largest(a, b, c) that takes three numbers and returns the largest of them. Don't use Python's max(): the point is to compare the numbers yourself, with if and >.

The numbers can be negative or decimals, and two or all three can be equal. When the largest value appears more than once, return that value.

Example 1

Inputa = 3, b = 9, c = 4
Output9
Explanation9 is bigger than both 3 and 4.

Example 2

Inputa = -1, b = -7, c = -3
Output-1
Explanation-1 is bigger than -3 and -7.

Example 3

Inputa = 5, b = 8, c = 8
Output8
Explanation8 appears twice and is still the largest.

Constraints

  • a, b and c are whole numbers or decimals from -1000 to 1000.

Submit also runs 4 more tests you can't see.

Practises Booleans and Comparisons (lesson 7).

Code
def largest(a, b, c):
    """Return the largest of three numbers, without max().

    a, b, c: int or float
    Returns: int or float, the biggest of the three
    """
    # Write your code here
    pass