How to Find the Largest Among Three Numbers using Python?


You can create a list of the three numbers and call the max method to find the largest among them.

 example

my_list = [10, 12, 3]
print(max(my_list))

Output

This will give the output −

12

Example

If you want to calculate it yourself, you can create a simple function like

def max_of_three(a, b, c):
   if a > b and a > c:
      return a
   elif b > c:
      return b
   else:
      return c
print(max_of_three(10, 12, 3))

Output

This will give the output −

12

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 05-Mar-2020

854 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements