This is a very Basic Program in Python. In this post we will take 2 numbers as Input and in Output we will see the greatest number from two numbers. We can write this program in many ways. A simple if else condition can be written and also we can use the max().

1. Maximum of Two numbers using if else Statement

#maximum of 2 numbers using if else condition
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
if(num1 > num2):
  print(num1, "is greater")
elif(num1 < num2):
  print(num2, "is greater")
else:
  print("Both numbers are same")

Output:

2. Maximum of two numbers using max() function

#maximum of 2 numbers using max()
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
maxValue = max(num1,num2)
print("max of 2 numbers is: ", maxValue)  

Output:

3. Maximum of two numbers using Ternary Operator

#maximum of 2 numbers using Ternary Operator
num1 = int(input("Enter First Number: "))
num2 = int(input("Enter Second Number: "))
maxValue = num1 if num1 >= num2 else num2
print("max of 2 numbers is: ", maxValue)

Output:

I hope this article will help you. You can share your feedback in comments section.
Happy Coding!