Question

In: Computer Science

This phyton program takes in three integer parameters and displays them in ascending order. You can...

This phyton program takes in three integer parameters and displays them in ascending order. You can assume that the numbers entered are integers. You CAN'T use lists, min(), max(), or the sort utility.  The point is to use if tests. 

sortThreeIntegers( 39, 2, 5 ) should display:
The numbers in order are: 2 5 39

sortThreeIntegers( 14, -12, -1000 ) should display:
The numbers in order are: -1000 -12 14
def sortThreeIntegers( x, y, z ):
   < your code goes here >

Solutions

Expert Solution

def sortThreeIntegers(a,b,c):
    print("The numbers in order are: ",end="")
    if (a <= b and a <= c):
        print(a, end=" ")
        if (b <= c):
            print(b, end=" ")
            print(c, end="")
        else:
            print(c, end=" ")
            print(b, end="")
    elif (b <= a and b <= c):
        print(b, end=" ")
        if (a <= c):
            print(a, end=" ")
            print(c, end="")
        else:
            print(c, end=" ")
            print(a, end="")
    else:
        print(c, end=" ")
        if (a <= b):
            print(a, end=" ")
            print(b, end="")
        else:
            print(b, end=" ")
            print(a, end="")
    print()
    

# Testing
sortThreeIntegers(39,2,5)
sortThreeIntegers(14,-12,-1000)


Related Solutions

Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Write a program that will ask the user for three words (strings). Re-arranges them in ascending...
Write a program that will ask the user for three words (strings). Re-arranges them in ascending order by using a function (it should return void). Global variables are forbidden. Hint: You don't need to exchange the values among variables. You can just print them in the correct order. (C++ Please) Example of Output: Word 1: apple Word 2: orange Word 3: strawberry -------- orange apple strawberry
Write a function called fillList that takes three parameters, an integer array, input file, and size....
Write a function called fillList that takes three parameters, an integer array, input file, and size. The function should fill the integer array with randomly generated values between two numbers lowLim and highLim read from the input file. in C++
Write a method, remove, that takes three parameters: an array of integers, the length of the array, and an integer called removeItem.
Java programming:Write a method, remove, that takes three parameters: an array of integers, the length of the array, and an integer called removeItem. The method should find and delete the first occurrence of removeItem in the array. If the value does not exist or the array is empty, output an appropriate message. (Note that after deleting the element, the array size is reduced by 1.) You may assume that the array is unsorted.Now re-do this exercise and name it ExInsertionSort....
c++ A program that displays the status of an order. a) Program uses 2 functions (in...
c++ A program that displays the status of an order. a) Program uses 2 functions (in addition to main ()). b) The first function asks the user for the data below and stores the input values in reference parameters. c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate. d) The second function receives as arguments any values needed to compute and display the...
a program that takes an integer and outputs the resulting factorial number.
assembly x86 language program a program that takes an integer and outputs the resulting factorial number. 
This Program is Written in PHYTON In geomrety, the value of π can be estimated from...
This Program is Written in PHYTON In geomrety, the value of π can be estimated from an infinite series of the form: π / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ... However, there is another novel approach to calculate π. Imagine that you have a dartboard that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine...
This Program is Written in PHYTON In geomrety, the value of π can be estimated from...
This Program is Written in PHYTON In geomrety, the value of π can be estimated from an infinite series of the form: π / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ... However, there is another novel approach to calculate π. Imagine that you have a dartboard that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine...
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
c++ Write a program that displays the status of an order. a) Program uses 2 functions...
c++ Write a program that displays the status of an order. a) Program uses 2 functions (in addition to main ()). b) The first function asks the user for the data below and stores the input values in reference parameters. c) Input data from user: # of spools ordered, # of spools in stock, any special shipping & handling charges over and above the $10 rate. d) The second function receives as arguments any values needed to compute and display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT