45
86
Sample Output:86
max()
max()
function in Python simplifies finding the greater number between two inputs.max()
function to find the larger of the two numbers.# Python program to find the greatest of two numbers using the built-in function
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
print(max(num1, num2), "is greater")
Input:Enter the first number: 23
Enter the second number: 45
Output:45 is greater
if-else
Statementsif-else
block.# Python Program to find the greatest of two numbers using if-else statements
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if a >= b:
print(a, "is greater")
else:
print(b, "is greater")
Input:Enter the first number: 50
Enter the second number: 45
Output:50 is greater
# Python Program to find the largest of two numbers using an arithmetic operator
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
if a - b > 0:
print(a, "is greater")
else:
print(b, "is greater")
Input:Enter the first number: 90
Enter the second number: 100
Output:100 is greater
max()
function is a quick and efficient way, while if-else
statements and arithmetic operations offer more control and clarity for beginners.