Python Program to Find the Largest Among Three Numbers

Posted in

Python Program to Find the Largest Among Three Numbers
vinaykhatri

Vinay Khatri
Last updated on November 24, 2024

    In this Python tutorial, you will learn how to write a python program to find the Largest Number Among Three numbers.

    Prerequisite for Python Program to Find the Largest Among Three Numbers

    Steps

    • First, we ask the user to enter 3 numbers.
    • Using the float() function we will convert the entered values into floating number values.
    • Using the if….elif  statement and comparison operators, we check for conditions.

    Python Program to Find the Largest Among Three Numbers

    Python Code

    num_1 = float(input("Enter First Number: "))
    num_2 = float(input("Enter Second Number: "))
    num_3 = float(input("Enter the Third Number: "))
    
    if num_1 > num_2 and num_1> num_3:
        print("The largest number is:", num_1)
    elif num_2 > num_1 and num_2>num_3:
        print("The largest number is:", num_2)
    else:
        print("The largest number is:", num_3)

    Output 1:

    Enter First Number: 19
    Enter Second Number: 19
    Enter the Third Number: 20
    The largest number is: 20.0

    Output:2

    Enter First Number: 1009
    Enter Second Number: 123
    Enter Third Number: 2652
    The largest number is: 2652.0

    People are also reading:

    Leave a Comment on this Post

    0 Comments