Maximum of Three

Write a Python program that takes in three integers from the user and finds out which number is the greatest. Print the greatest number.

Example:

Input: 3, 7, 5 

Output: The greatest number is 7.

Use if-else statements to compare the three numbers.

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a > b and a > c:
print(f"The greatest number is {a}.")
elif b > a and b > c:
print(f"The greatest number is {b}.")
else:
print(f"The greatest number is {c}.")

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!