Answer to Question #261589 in Python for Mikee

Question #261589

8. Sort It Yourself

by CodeChum Admin

A descending order means values arranged from largest to smallest. But in your case, you're going to have to sort these integers in ascending order, which means from smallest to largest.


Instructions:

  1. Input three integers.
  2. Print the integers in ascending order using your knowledge on conditional statements.

Instructions

  1. Input three integers.
  2. Print the integers in ascending order.

Input

A line containing three integers separated by a space.


6·1·3

Output

A line containing three integers separated by a space.


1·3·6
1
Expert's answer
2021-11-10T03:01:21-0500
f = map(int, input().split())
if len(f) == 3:
  if f[0] < f[1] and f[0] < f[2]:
    if f[1] < f[2]:
      print(f[0], f[1], f[2])
    else:
      print(f[0], f[2], f[1])
  elif f[1] < f[0] and f[1] < f[2]:
    if f[0] < f[2]:
      print(f[1], f[0], f[2])
    else:
      print(f[1], f[2]. f[0])
  else:
    if f[0] < f[1]:
      print(f[2], f[0], f[1])
    else:
      print(f[2], f[1], f[0])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS