Skip to content
Home » Python Program to Find the Largest among Three Numbers

Python Program to Find the Largest among Three Numbers

Learn about Python Program to Find the Largest among Three Numbers in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Python Program to Find the Largest among Three Numbers

Three numbers are read from the user and stored in variables num1, num2, and num3. Following that, the largest of the three is chosen using Python’s if elif else statement.

Source code:

# Python program to find largest of 3 numbers

# inputs
num1 = 5
num2 = 3
num3 = 9

# find the largest of 3 numbers
if (num1 >= num2) and (num1 >= num3):
    largest = num1
elif (num2 >= num1) and (num2 >= num3):
    largest = num2
else:
    largest = num3

# print result
print('The largest number = ', largest)

Output:

The largest number = 9

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Sum of Digits of a Number using List in Python