Python program to find largest of 3 numbers

Python program to find largest of 3 numbers : The python is very easy to find the minimum, maximum elements and, position. It will provide the inbuilt functions as the min (), max () and max is used to find out the maximum values in the array. The max() method will return the largest element or largest element of two or more parameters. The program explanation to find out the largest number between two numbers. We can use the same method for the floating-point numbers in the python programming to find out the largest number among the three numbers.

1) Simple using nested if else/elif statement Example:-

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)
Output:-
Enter first number: 10
Enter first number: 15
Enter first number: 22
The largest number is 2

2) Example using list:-

Steps:-

  1. Initializing the three numbers by the n1, n2, and n3.
  2. Then add the numbers in the lists= [n1, n2, n3]
  3. Then using the max () function you can find the greatest number as the max (list)
  4. Then we can print the maximum number.

Example:-
defmaximum (a, b, c):
list= [a, b, c]
return max (list)
a=10
b=14
c=12
print (maximum (a, b, c))
Output:-
14

Additional Services : Refurbished Laptops Sales, Python Classes, Share Market Classes And SEO Freelancer in Pune, India