python
Write a program to find the largest value. Ask the user to enter
three numbers. Compare them and report the largest one. [Hint: The
user is free to enter any three numbers. Some or all of them may be
the same. Take this into consideration when you compare the
numbers.]
The following are some examples.
Enter first number: 7
Enter second number: 14
Enter third number: 10.5
The largest number is: 14.0
Enter first number: 17
Enter second number: 15
Enter third number: 17
The largest number is: 17.0
Enter first number: 7
Enter second number: 7
Enter third number: 7
The largest number is: 7.0
CODE:
# ask user to enter three numbers
first_number = float(input("Enter first number:"))
second_number = float(input("Enter second number: "))
third_number=float(input("Enter third number: "))
if (first_number >= second_number) and (first_number >=
third_number):
largest_number = first_number
elif (second_number >= first_number) and (second_number >=
third_number):
largest_number = second_number
else:
largest_number = third_number
print("The largest number is ",largest_number)
Output:
Get Answers For Free
Most questions answered within 1 hours.