This program is similar to the previous one, with a single modification, here we will use if else statement to find the largest number.

Logic

The logic to find the largest number among the three numbers, we have to compare each number with the other two numbers.

Let three variables be: A = 400, B = 200 and C = 300

  1. if A > B and A > C, then print A.
  2. else if B > A and B > C, then print B.
  3. else print C.

Program

# Take 3 numbers from user
num1 = int(input("Enter 1st number : "))

num2 = int(input("\nEnter 2nd number : "))

num3 = int(input("\nEnter 3rd number : "))

# Check fro number 1, 2 and 3.
if num1 >= num2 and num1 >= num3 :
    print("\n" + str(num1), "is largest number")

elif num2 >= num3 :
    print("\n" + str(num2), "is largest number")

else :
    print("\n" + str(num3), "is largest number")

Output

Enter 1st number : 10
Enter 2nd number : 200
Enter 3rd number : 11
200 is largest number