Question: I need help with python. my teacher wants us to modify a program to complete the task. The attached image is the requirement here is
I need help with python. my teacher wants us to modify a program to complete the task. The attached image is the requirement
here is the program:
print(" This program will sort three integers in ascending order. ")
# Step 1. Ask a user to enter three integers int1 = int(input("Please enter an integer in the range of [-100, 100]: ")) int2 = int(input("Please enter another integer in the range of [-100, 100]: ")) int3 = int(input("Please enter one more integer in the range of [-100, 100]: "))
print(' ' + '*' * 30, " You entered: int1 =" + "%5i" % int1 + ", int2 =" + "%5i" % int2 + ", int3 =" + "%5i" % int3)
# Step 2. Sort the first two numbers in ascending order
# Add your code for Step 2 here
# Step 3. Show the result after the first two numbers have been sorted print(" After the first two numbers sorted: int1 =" + "%5i" % int1 + ", int2 =" + "%5i" % int2 + ", int3 =" + "%5i" % int3)
# Step 4. Sort all three numbers in ascending order
# Add your code for Step 4 here
# Step 5. Show the result after all three numbers have been sorted print(" The final sorted result: int1 =" + "%5i" % int1 + ", int2 =" + "%5i" % int2 + ", int3 =" + "%5i" % int3)
SC 130: The World of Computer Science Spring 2018, MSU Homework 7 (Week 12) Due: 4/6 (5 minutes before the class starts) Purpose To learn use of ifstatements. What to do: 1. Copy the give incomplete program sort.pv and data files from Trace to folder C:lTemp 2. The incomplete program is to sort three numbers entered by a user in ascending order (i.e. a smallest number of intl, int2, and int3 should be stored in intl, a middle number of the three should be stored in int2, and a biggest number of the three should be stored in int3 or intlsint2sint3. For example, if the user entered 7 for int1, 35 for int2, and -5 for int3, then, the program needs to change the content of intl to -5, int2 to 7, and int3 to 35; if the user entered 4 for intl, 8 for int2, and 4 for int3, then, it needs to change the content of int2 to 4, and int3 to 8; etc. Execute the program to make sure that your copy works appropriately at this stage (note: report errors to the instructor if there are any) 3. Add a section of code for Step 2 of the program that sorts the contents of int1 and int2 in ascending order Hint: Consider what you have to do if you need to swap the content of a glass of water with that of a glass of milk in a real life situation. 4. Add a section of code for Step 4 of the program that sorts the contents of intl, int2, and int3 in ascending order. Hint: notice that intl and int2 are in ascending order now 5. Update the documentation part of the program accordingly Note: Do not add any output statement in Step 2 and Step 4 of the program. 2 Do not change any code that is given
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
