Python Exercise: Find the Max of three numbers
1. Maximum of Three Numbers
Write a Python function to find the maximum of three numbers.
Sample Solution:
Python Code:
Sample Output:
6
Explanation:
In the exercise above the code defines two functions: "max_of_two()" which finds the maximum between two numbers, and "max_of_three()" which finds the maximum among three numbers by utilizing the "max_of_two()" function. In the final print statement, the maximum is found among the given numbers: 3, 6, and -5.
Pictorial presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python function that takes three parameters and returns the largest using nested ternary operators.
- Write a Python function that finds the maximum of three numbers without using the built-in max() function by using if-else statements.
- Write a Python function that accepts three numbers in a list and uses recursion to determine the maximum value.
- Write a Python function that sorts three numbers and returns the last element as the maximum, ensuring the original order is preserved.
Go to:
Previous: Python-Functions-Exercises Home.
Next: Write a Python function to sum all the numbers in a list.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.