Programming Examples

Python program to input three number and print in ascending order


Write Python program to input three number and print in ascending order

Solution

num1=int(input("Enter First number : "))
num2=int(input("Enter Second number : "))
num3=int(input("Enter Third number : "))
if num1<num2 and num1<num3:
    if num2<num3:
        x,y,z=num1,num2,num3
    else:
        x,y,z=num1,num3,num2
elif num2<num1 and num2<num3:
    if num1<num3:
        x,y,z=num2,num1,num3
    else:
        x,y,z=num2,num3,num1
else:
    if num1<num2:
        x,y,z=num3,num1,num2
    else:
        x,y,z=num3,num2,num1
print("Numbers in ascending order are : ",x,y,z)
Output/ Explanation:

Enter First number : 50

Enter Second number : 45

Enter Third number : 100

Numbers in ascending order are :  45 50 100

>>> 

======================== 

Enter First number : 30

Enter Second number : 20

Enter Third number : 10

Numbers in ascending order are :  10 20 30

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad