Last Updated : 12 Jul, 2025
In this article, we will explore various methods to find minimum of two numbers in Python. The simplest way to find minimum of two numbers in Python is by using built-in min() function.
Python
a = 7
b = 3
print(min(a, b))
Explanation:
Let's explore other different method to find minimum of two numbers:
Using Conditional StatementsAnother way to find the minimum of two numbers is by using conditional statements like if and else. This approach gives us more control over the logic and is useful when we need to implement custom rules.
Python
a = 5
b = 10
if a < b:
print(a)
else:
print(b)
Explanation:
Python also supports a shorthand version of conditional statements known as the ternary operator. It allows us to write concise conditional expressions on a single line.
Python
a = 7
b = 2
res = a if a < b else b
print(res)
Explanation:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4