Question: In this lab, you will complete a Python program that swaps values stored in three int variables and determines maximum and minimum values. The Python

In this lab, you will complete a Python program that swaps values stored in three int variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary variable initializations, as well as the input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write statements that compare the values and swap them, if appropriate. Comments included in the code tell you where to write your statements
Instructions
Write the statements that test the first two integers and swap them, if necessary.
Write the statements that test the second and third integer and swap them, if necessary.
Write the statements that test the first and second integers again and swap them, if necessary.
Execute the program using the following sets of input values:
1012223
63015009
2122
Swap.py - This program determines the minimum and maximum of three values input by
# the user and performs necessary swaps.
# Input: Three int values.
# Output: The numbers in numerical order.
# Initialize variables.
first =0
second =0
third =0
# Get user input.
firstNumber = input("Enter first number: ")
if firstNumber !="":
secondNumber = input("Enter second number: ")
thirdNumber = input("Enter third number: ")
# Convert strings to int.
first = int(firstNumber)
second = int(secondNumber)
third = int(thirdNumber)
# Test to see if the first number is greater than the second number.
# Test to see if the second number is greater than the third number.
# Test to see if the first number is greater than the second number again.
# Print values in numerical order.
print("Smallest:", first)
print("Next largest:", second)
print("Largest:", third)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!