In this post, we will see how to find largest among three number.
This will test your knowledge for if, elif and else.This is very straightforward program.
# Python program to find the largest number among the three input numbers #Take three inputs num1 = 6 num2 = 3 num3 = 9 # uncomment following lines to take three numbers from user #num1 = int(input("Enter first number: ")) #num2 = int(input("Enter second number: ")) #num3 = int(input("Enter 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 among",num1,",",num2,"and",num3,"is",largest)
The largest number among 6 , 3 and 9 is 9
That’s all about find largest number among three numbers.