Python

Python Program to Find the Largest Among Three Numbers2 min read

Write a program to Find the Largest Among Three Numbers in Python

Code:




This Python program takes three inputs from the user, num1, num2 and num3 and finds the largest number among the three.

The program starts by asking the user to input the three numbers, num1, num2 and num3, which are stored as floats.

Then, the program uses if-elif statements to check which of the three input numbers is the largest. It first checks if num1 is greater than or equal to num2 and num1 is greater than or equal to num3. If this is true, it assigns the value of num1 to the variable “largest”. If this is false, it then checks if num2 is greater than or equal to num1 and num2 is greater than or equal to num3. If this is true, it assigns the value of num2 to the variable “largest”. If this is false, it assigns the value of num3 to the variable “largest”

Finally, the program prints the sentence “The largest number between num1, num2 and num3 is largest” where num1, num2 and num3 are the inputs provided by the user and largest is the largest number among the three.

The output will be a string indicating the largest number among the three input number.

Example 2:

 Video:

Leave a Comment