Learn about Largest among Three Numbers using max() Function in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Largest among Three Numbers using max() Function in Python
The numbers num1, num2, num3 are the user inputs and the
max() function is used to find the largest number from the given numbers.
# Python program to find the largest among num1 = float(input('first number: ')) num2 = float(input('second number: ')) num3 = float(input('third number: ')) # max() function print('The largest number = ', max(num1, num2, num3))
first number: 3 second number: 7 third number: 5 The largest number = 7.0
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Find the Largest among Three Numbers