Find Biggest of Three Numbers in Python

Beginner
⏱️ 9 min read
📚 Updated: May 2026
🎯 2 Code Examples
Conditionals

What you’ll learn

  • How to find the largest of three numbers using a clear if-elif-else ladder.
  • How the same result can be written with max(a, b, c) or nested max style.
  • How tie cases (equal values) behave, and how to explain complexity in interviews.

Overview

Given a, b, and c, return the value that is not smaller than the other two. If two or three values tie for largest, returning any one of those tied largest values is valid.

Quick examples

14, 7, 22Max 22
5, 5, 3Max 5
-1, -4, -2Max -1

Live preview

Enter three numbers and check the biggest value instantly.

Live result
Press "Run" to see the biggest value.

Algorithm

Check a

If a >= b and a >= c, return a.

Else check b

If b >= a and b >= c, return b.

Otherwise return c

If first two checks fail, c is biggest.

📜 Pseudocode

Pseudocode
function find_biggest(a, b, c):
    if a >= b and a >= c:
        return a
    if b >= a and b >= c:
        return b
    return c
1

If-elif-else approach

python
def find_biggest(num1: int, num2: int, num3: int) -> int:
    if num1 >= num2 and num1 >= num3:
        return num1
    elif num2 >= num1 and num2 >= num3:
        return num2
    return num3


number1 = 14
number2 = 7
number3 = 22
result = find_biggest(number1, number2, number3)
print(f"The biggest number is: {result}")
2

Built-in max() approach

python
def find_biggest_with_max(a: int, b: int, c: int) -> int:
    return max(a, b, c)


a, b, c = 14, 7, 22
print(f"The biggest number is: {find_biggest_with_max(a, b, c)}")

❓ FAQ

You compare the values using if-elif conditions, or use max(a, b, c). Both return the largest value.
Using >= handles ties clearly. If two numbers are equal and largest, one valid maximum is still returned correctly.
Yes. You can directly use max(a, b, c). In interviews, writing the if-elif version first helps show your logic.
For exactly three numbers, time complexity is O(1) and extra space is O(1).
Yes. Comparisons work the same way for negative values too.
Use a loop with a running maximum, or max() on a list/array of values.

Edge cases and pitfalls

Ties

Equal largest values

For input like 5, 5, 3, the answer is still 5.

Negatives

All values negative

The greatest value is the least negative number.

Input type

Int vs float

The same idea works for floats too; just change type hints if needed.

⏱️ Time and space complexity

ApproachTimeExtra space
If-elif checks for 3 numbersO(1)O(1)
Built-in max(a, b, c)O(1)O(1)

Summary

  • Goal: find the largest of 3 values.
  • Methods: if-elif-else comparisons or max().
  • Complexity: constant time and constant extra space.
Did you know?

To find the biggest of 3 values, you only need a few comparisons, so the solution runs in O(1) time and O(1) space.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful