Python program to find the largest of three numbers

Description: Write a Python program to find the largest of three numbers.

Rules and hints:

  • First use if, elif and else.
  • Then try the built-in max() function.

Python program to find the largest of three numbers

a = 25
b = 78
c = 42

if a >= b and a >= c:
    largest = a
elif b >= a and b >= c:
    largest = b
else:
    largest = c

print("Largest number is", largest)
print("Using max():", max(a, b, c))

Output:

Tutorials Class - Output Window

Largest number is 78
Using max(): 78

How it works

  • The first condition checks if a is bigger than or equal to both others.
  • If not, the elif checks b. If both fail, c must be the largest.
  • max() does all this work in one call, so use it in real programs.

Learn more about the similar topics:
Tutorials
Python Conditional Statements
Python While Loop
Python for loop
Python Jump Statements
Exercises & Assignments
Python program to check even or odd number
Python program to find the largest of three numbers
Python program to check leap year
Python program to print multiplication table
Python program to find factorial of a number
Python program to print Fibonacci series
Python program to check prime number
Interview Questions & Answers
No Content Found.