Find elements

Python program to find middle of three number using function

Python program to find  middle of three number using function

In this tutorial, We will discuss the concept of the Python program to find middle of three number using function

This post describes how to find the middle number among three numbers using if elif statements in Python language

There are many ways to find the middle number of the three numbers. but here, we mainly focus if-elif statements to find the middle number in Python.

Find middle number

 

Using Nested if elif statements  to find the middle

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

def middleNum():#function definition
    middle=0;
    if(num1>num2):
        if(num2>num3):
           middle=num2;
    
        elif(num3>num1):
           middle=num1;
    
        else:
            middle=num3;

    else:

        if(num2<num3):
            middle=num2;
    
        elif(num3<num1):
            middle=num1;
    
        else:
            middle=num3;
    
    print("middle number is",middle);
middleNum();#function call

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

Enter the first number: 66
Enter the second number: 54
Enter the third number: 32
middle number is 54

 

Similar post

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

C++ program 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 program to find middle of three numbers

C++ program 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 program to find the middle of three number using the function

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

 

 

 

Suggested for you

The operator in Python language

If statement in Python language

function in Python

Data types and Variable in Python

 

 

 

 

C program to find middle among three number using function
Java program to find middle of three number using method
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

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 days ago

C# inverted full pyramid star pattern

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

3 weeks ago

C# Full Pyramid star pattern program

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

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago