18. Write a python program to request user to input 3 random numbers therefore sort the them in increasing order without using conditional statement.
The output is:
Example:
Please input the first number: 9
Plese input the second number: 2
Please input the third number: 5
Expected Answer:
The numbers in increasing order: 2 5 9
Answer:
input_1 = int(input("Please input the first number: ")) input_2 = int(input("Plese input the second number: ")) input_3 = int(input("Please input the third number: ")) min_num = min(input_1, input_2, input_3) max_num = max(input_1, input_2, input_3) mid_num = (input_1 + input_2 + input_3) - min_num - max_num print("The numbers in increasing order: ", min_num, mid_num, max_num)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)