Python - Find the Largest Number Among Three Numbers

In this program, you will learn how to find the largest number among three numbers.


Program Code



    # Enter the numbers
    num1 = int(input('Enter the first number: '))
    num2 = int(input('Enter the second number: '))
    num3 = int(input('Enter the third number: '))
    
    if (num1 >= num2) and (num1 >= num3): 
        largest = num1
    elif (num2 >= num1) and (num2 >= num3):
        largest = num2
    else:
        largest = num3
    
    print('The largest number is', largest)

Output



    Enter the first number: 555
    Enter the second number: 777
    Enter the third number: 333
    The largest number is 777

In this program, the num1, num2 and num3 variables are holding the values for given numbers.
We are using if...else conditons to find the largest number. In first if condition, checking num1 is largest number. If not, checking num2 is largest number in 2nd if condition. Otherwise, num3 is the largest number.



The following topics can be useful to understand this program.



Related Tutorials