Find elements

Python program:find greatest of three numbers using function

Python program:find the greatest of three numbers using the function

In this tutorial, we will discuss the concept of the Python program:find the greatest of three numbers using the function

In this post, we will learn how to find the greatest number of three numbers using a user-defined function in the Python programming language

Python program: find the greatest

In my previous post, I have explained the various approaches to find the largest number of among  three numbers in Python language

However, in this program, we embed the logic of this program in the function.

Here, I have explained how to find the greatest number from the given three numbers and how to embed this logic in the function.

Program 1

Find the greatest of three numbers using if elif statements

This program allows the user to enter three numbers and compare to select the largest number using if-elif statements

num1=int(input("Enter the first number: "));
num2=int(input("Enter the second number: "));
num3=int(input("Enter the Third number: "));

def find_Biggest():      #function definition
     if(num1>=num2) and (num1>=num2):
         largest=num1
     elif(num2>=num1) and (num2>=num3):
         largest=num2
     else:
         largest=num3

     print("Largest number is",largest)

find_Biggest();         #function call

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

Enter the first number: 23
Enter the second number: 78
Enter the Third number: 54
Largest number is 78

 

 

Program 2

Find the greatest of three numbers using nested if statements

This program allows the user to enter three numbers and compare to select the largest number using nested if statements

num1=int(input("Enter the first number: "));
num2=int(input("Enter the second number: "));
num3=int(input("Enter the Third number: "));

def find_Biggest1():#function definition
    if(num1>num2):
        if(num1>num3):
             largest=num1
        else:
             largest=num3
    else:
        if num2>num3:
            largest=num2
    
        else:
            largest=num3
        #Display the laegest number
            
        print("Largest number is: ",largest)
        
find_Biggest1();#function call

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

Enter the first number: 36
Enter the second number: 79
Enter the Third number: 98
Largest number is: 98

 

Similar post

C program to find the largest among three numbers using function

Python code to find the largest of three numbers using the function

C++ code to find the largest of three numbers using the function

Java code to find the largest of three numbers

C code to find the largest of three numbers

C++ code to find the largest of three numbers

Python code to find the largest of three numbers

Java program to find the middle of three number using Method

C code to find the middle of three number using the function

C++ code to find the middle of three number using the function

Python code to find the middle of three number using the function

Java code to find middle of three numbers

C code to find middle of three numbers

C++ code to find middle of three numbers

Python code to find middle of three numbers

Java code to find largest of three numbers in an array

Java code to find smallest of three numbers in an array

C code to find the middle of three number using the function

C++ code to find the middle of three number using the function

 

Suggested for you

The operator in C++ language

If statement in C++ language

Nested if statement in C++ language

Data type in C++ language

Variable in C++ language

 

Operator in C language

If statement in C language

Data type in C language

Variable in C language

 

The operator in Python language

If statement in Python language

function in Python

Data types and Variable in Python

 

Datatype and variables in Java programming language

Operator in Java language

If statements in Java language

Method in Java language

 

 

C program:find greatest of three numbers using function
Cpp program:find smallest of three numbers using function
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…

19 hours 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…

1 week ago

C# inverted full pyramid star pattern

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

4 weeks 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