Find elements

Python program to find largest number among three numbers

Python program to find largest number among three numbers

In this tutorial, we will discuss the Python program to find largest number among three numbers.

This post explains how to find the largest number among three numbers using if statements with the operator in Python.

There are many ways to find the largest number among the three numbers in Python. but here,  we use if elif statements and with the and operator.

find the largest number among three numbers

Here, we provide two programs to find the largest number among the three numbers.

first program leads to find the largest number among three integer numbers.

Second program leads to find the largest number among three floating point numbers.

 

Find the largest number among three integer numbers

Program 1

num1=int(input("Enter the first number: "))
num2=int(input("Enter second number: "))
num3=int(input("Enter the third number: "))
#get input from user for num1,num2,num3

if(num1>num2) and (num1>num3):
    biggest=num1;
#check whether the num1 is smaller than num2 and num3

elif (num2>num1) and (num2>num3):
    biggest=num2;
#check whether the num2 is smaller than num1 and num3

else:
    biggest=num3;

print("The largest number is",biggest);

When the above code is executed, it produces the following results

Enter the first number: 98
Enter second number: 65
Enter the third number: 43
The largest number is 98

This program takes input from the user for num1,num2, num3. then, this program finds and displays the largest number among the three integer numbers

Find the largest number among three floating point numbers

Program 2

num1=float(input("Enter the first number: "))
num2=float(input("Enter second number: "))
num3=float(input("Enter the third number: "))
#get input from user for num1,num2,num3

if(num1>num2) and (num1>num3):
    biggest=num1;
#check whether num1 is smaller than num2 and num3

elif (num2>num1) and (num2>num3):
    biggest=num2;
#check whether the num2 is smaller than num1 and num3

else:
    biggest=num3;

print("The largest number is",biggest);

When the above code is executed, it produces the following results

Enter the first number: 23.65
Enter second number: 78.45
Enter the third number: 67.34
The largest number is 78.45

 

This program takes input from the user for num1,num2, num3. then, this program finds and displays the largest number among the three decimal numbers

Suggested for you

If statement in Python language

Operator in Python language

C program to find largest and second largest elements in array
Python program to find Average of numbers in a list
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

Explanation of one dimensional array (Data structure)

Explanation of one dimensional array In this post, we will discuss the concept of "Explanation…

1 day ago

Python program to calculate the sum of odd and even numbers in a list

Python program to calculate the sum of odd and even numbers in a list In…

4 days ago

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

1 week ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 weeks ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 month ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

2 months ago