Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Find Maximum of Two

Return the larger of two numbers (int or float). If they are equal, return that value.

Python practice6 minControl Flow (If–Else Logic)BeginnerLast updated March 15, 2026

Problem statement

Write a function find_max(a, b) that takes two numbers (integers or floats) and returns the larger value. If both numbers are equal, return that value. Use conditional logic (if/else) to compare the two values. Do not use built-in functions like max() in your implementation.

Task

Implement a function find_max(a, b) that returns the greater of the two numeric inputs.

Examples

Simple comparison

Input

find_max(2, 5)

Output

5

5 is greater than 2, so the function returns 5.

Input format

Two numbers a and b are provided as function arguments: find_max(a, b).

Output format

Return the larger number (int or float).

Constraints

Inputs a and b are numbers (int or float). You may assume both inputs are valid numbers. Don't use built-in max() for the core logic.

Samples

Sample 1

Input

find_max(-3, -7)

Output

-3

Between -3 and -7, -3 is greater.