Python Program to find the Largest of Three Numbers

In this tutorial, we will discuss a Python Program to find the Largest of Three Numbers.

This is a common problem that can be solved using simple conditional statements.

Related: Python Program for Compound Interest Calculator

Program code for finding the largest of three numbers using Python

# Largest of Three Numbers in Python
def find_largest(a, b, c):
    if a >= b and a >= c:
        return a
    elif b >= a and b >= c:
        return b
    else:
        return c

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))
print(f"The largest of {num1}, {num2}, and {num3} is {find_largest(num1, num2, num3)}.")

Explanation

  1. Function Definition: The find_largest function takes three integers a, b, and c as input and returns the largest of the three numbers.
  2. Conditional Statements: The function uses conditional statements to compare the numbers and determine the largest.
  3. Main Program: The program prompts the user to enter three numbers and then finds the largest of the three using the find_largest function.

Output

Python Program to find the Largest of Three Numbers

  • When you run the above program, it will prompt you to enter three numbers.
  • After entering the numbers, it will find the largest of the three and print the result.

Conclusion

  • In this tutorial, we learned how to find the largest of three given numbers using a Python program.
  • Understanding this concept is essential for solving various mathematical problems and competitive programming challenges.
  • Practice this example to enhance your programming skills and understanding of conditional statements.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *