python program to print the greatest of three numbers code example
Example 1: program to find the largest of three numbers in python
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if (num1 > num2) and (num1 > num3):
largest = num1
elif (num2 > num1) and (num2 > num3):
largest = num2
else:
largest = num3
print("The largest number is",largest)
Example 2: how to find greatest number in python
Method 1 : Sort the list in ascending order and print the last element in the list.
filter_none
edit
play_arrow
brightness_4
list1 = [10, 20, 4, 45, 99]
list1.sort()
print("Largest element is:", list1[-1])
Output:
Largest element is: 99