wap in python that reads three numbers and print them in ascending order
Answers
Answer:
def main():
x = input( "Enter a number >> ")
y = input( "Enter a second number >> ")
z = input( "Enter a third number >> ")
if x == y:
print "Those numbers are the same!"
elif y == z:
print "Those numbers are the same!"
elif x == z:
print "Those numbers are the same!"
elif x < y < z:
print "%d, %d, %d" % (x, y, z)
elif x < y < z:
print "%d, %d, %d" % (x, z, y)
elif x < y < z:
print "%d, %d, %d" % (y, x, z)
elif x <y < z:
print "%d, %d, %d" % (y, z, x)
elif x < y < z:
print "%d, %d, %d" % (z, x, y)
else:
print "%d, %d, %d" % (z, y, x)
main()
Answer:
x = int(input("Input first number: "))
y = int(input("Input second number: "))
z = int(input("Input third number: "))
a1 = min( x, y, z) a3 = max( x, y, z)
a2 = ( x + y + z) - a1 - a3
print("Numbers in sorted order: ", a1, a2, a3)