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

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago