Saturday, 16 May 2015

Python Program to find the Biggest and Smallest of 3 numbers


This is a Python program  which finds out the smallest and biggest numbers  of 3 numbers.Here we use 2 functions smallest() and biggest() to check for the smallest and biggest number respectively.

PROGRAM :
num1 = int(input('Enter First number : '))
num2 = int(input('Enter Second number : '))
num3 = int(input('Enter Third number : '))


def largest(num1, num2, num3):
    if (num1 > num2) and (num1 > num3):
        largest = num1
    elif (num2 > num1) and (num2 > num3):
        largest = num2
    else:
        largest = num3
    print("The largest of the 3 numbers is : ", largest)


def smallest(num1, num2, num3):
    if (num1 < num2) and (num1 < num3):
        smallest = num1
    elif (num2 < num1) and (num2 < num3):
        smallest = num2
    else:
        smallest = num3
    print("The smallest of the 3 numbers is : ", smallest)


largest(num1, num2, num3)
smallest(num1, num2, num3)


OUTPUT : 
Python - Biggest and Smallest of 3 numbers



Similar Programs :
C Program to find the Biggest and Smallest of 3 numbers
Cpp Program to find the Biggest and Smallest of 3 numbers
Java Program to find the Biggest and Smallest of 3 numbers