In this article, we will write a python program to find the largest number among the three input numbers. To understand the following program, you should have the knowledge of following python concepts:
python program to find the largest number among the three input numbers
In the following python program, we are taking input from the user. User enters three numbers and program finds the largest among three numbers using if..elif..else statement. Here we are using float() function while taking input from the user so that we can accept the numbers in float values as well.
# Python program to find the largest among three numbers # taking input from user num1 = float(input("Enter 1st number: ")) num2 = float(input("Enter 2nd number: ")) num3 = float(input("Enter 3rd number: ")) if (num1 >= num2) and (num1 >= num3): lnum = num1 elif (num2 >= num1) and (num2 >= num3): lnum = num2 else: lnum = num3 print("The largest number among",num1,",",num2,"and",num3,"is: ",lnum)
Output:
Leave a Reply