Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Java program to Find Largest of three numbers

Python program to Find Largest of three numbers

Posted on March 23, 2021March 23, 2021

Table of Contents

  • Python program to Find Largest of three numbers
    • Code to find largest numbers
      • Code to find largest numbers  using if statements
      • Code to find largest numbers  using if elif statements – input from user
      • Code to find largest numbers  using function
      • Code to find largest numbers  using function – input from user
    • Related

Python program to Find Largest of three numbers

In this article, we will discuss the concept of Python program to Find Largest of three numbers

In this post, we are going to learn how to write a program to find largest number out of three numbers using different methods in Python program.

Code to find largest numbers

Code to find largest numbers  using if statements

In this code, we will find largest number out of three numbers using if statements in Python language

Program 1

num1=76
num2=98
num3=45
#variable declaration and initilaization

if(num1>num2) and (num1>num3):
biggest=num1;

elif (num2>num1) and (num2>num3):
biggest=num2;

else:
biggest=num3;

print("The largest number is",biggest)
#display result on the screen

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

The largest number is 98

 

Algorithm to find the greatest of three numbers using if-elif- else statements

  • Variable declaration and initialization
  • use an if-elif-else statements if(num1>num2) and (num1>num3), print num1
  • elif (num2>num1) and (num2>num3): print num2
  • Else  print num3
  • End of the program

 

Code to find largest numbers  using if elif statements – input from user

In this code, we will find largest number out of three numbers using if elif statements in Python language

Program 2

#Python program to find largest of three numbers
num1=int(input("Enter first number: "))
#reading the input value from user for num1
num2=int(input("Enter second number: "))
#reading the input value from user for num2
num3=int(input("Enter third number: "))
#reading the input value from user for num3

if(num1>num2) and (num1>num3):
    biggest=num1;

elif (num2>num1) and (num2>num3):
    biggest=num2;

else:
    biggest=num3;

print("The largest number is",biggest)
#display result on the screen

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

Enter first number: 5678
Enter second number: 4325
Enter third number: 56747
The largest number is 56747

 

Algorithm to find the greatest of three numbers using if-elif- else statements

  • Get three input from the user
  • use an if-elif-else statements if(num1>num2) and (num1>num3), print num1
  • elif (num2>num1) and (num2>num3): print num2
  • Else  print num3
  • End of the program

 

Code to find largest numbers  using function

In this code, we will find largest number out of three numbers using function in Python language

Program 3

#Python program to find largest of three numbers
num1=int(input("Enter the first number: "));
num2=int(input("Enter the second number: "));
num3=int(input("Enter the Third number: "));
#reading the input from the user
def find_Largest():#method definition
     if(num1>=num2) and (num1>=num3):
         largest=num1
     elif(num2>=num1) and (num2>=num3):
         largest=num2
     else:
         largest=num3

     print("Largest number is",largest)

find_Largest();#Calling the method

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

Enter the first number: 978
Enter the second number: 345
Enter the Third number: 654
Largest number is 978

 

Algorithm to find the greatest of three numbers using using function

  • Get three input from the user
  • define the function for find largest of three
  • Calling the function for display result
  • End of the program

 

Code to find largest numbers  using function – input from user

In this code, we will find largest number out of three numbers using function in Python language

Program 4

#Python program to find largest of three numbers
def find_Largest(num1,num2,num3):#method definition
     if(num1>=num2) and (num1>=num3):
         largest=num1
     elif(num2>=num1) and (num2>=num3):
         largest=num2
     else:
         largest=num3
     return largest
print("Enter three numbers")
num1=int(input());
num2=int(input());
num3=int(input());


print(find_Largest(num1,num2,num3))

 

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

Enter three numbers
567
234
1022
1022

 

Suggested post

Operator in Python language

Data types in Python language

If statements in Python language

Nested if statement in Python language

 

Similar post

Java program to find middle of three

C program to find middle of three

C++ program to find middle of three

Python program to find middle of three

 

Java program to Find largest of three numbers

C program to Find largest of three numbers

C++ program to Find largest of three numbers

Python program to Find largest of three numbers

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes