๐ Day 11/150 – Find the Largest of Three Numbers in Python
Welcome back to the 150 Days of Python series!
Today, we’re leveling up from two numbers to three numbers ๐ฅ
Finding the largest among three numbers helps you understand:
- Multiple conditions
- Logical comparisons
- Cleaner coding approaches
๐ฏ Problem Statement
Write a Python program to find the largest of three numbers.
✅ Method 1 – Using if-elif-else
The most common and beginner-friendly approach.
๐ Explanation:
We compare all three values step by step to determine the largest.
✅ Method 2 – Taking User Input
Make your program interactive.
a = float(input("Enter first number: ")) b = float(input("Enter second number: ")) c = float(input("Enter third number: ")) if a > b and a > c: print("Largest number is:", a) elif b > c: print("Largest number is:", b) else: print("Largest number is:", c)
๐ Why this matters:
User input makes your program practical and real-world ready.
✅ Method 3 – Using a Function
Reusable and clean solution.
๐ Pro Tip:
Functions help you organize and reuse your logic efficiently.
✅ Method 4 – Using Nested Conditions
Another way using nested if statements.
๐ Use Case:
Helps understand deeper conditional structures.
๐ง Summary
| Method | Best For |
|---|---|
| if-elif-else | Beginners |
| User Input | Real-world use |
| Function | Reusability |
| Nested if | Logical understanding |


0 Comments:
Post a Comment