by BehindJava
Write a program to check the largest of three numbers
In this tutorial we are going to learn about Writing a program to check the largest of three numbers.
Program to demonstrate the largest of three numbers.
There are many ways to find the largest of three numbers.
Method1:
we can use max() function in order to find the largest of three numbers.
l=[1,2,3]
largest=max(l)
print(largest)
Method 2:
num1=1
num2=2
num3=3
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)