Lesson guide
What this Python exercise practices
Find Maximum of Two is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 6 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 6 minutes
Summary
Return the larger of two numbers (int or float). If they are equal, return that value.
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
Explanation
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 input 0
find_max(-3, -7)
Sample output 0
-3
Explanation 0
Between -3 and -7, -3 is greater.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.