Question

THIS IS FOR PYTHON CODE Given 3 words, print the three words in alphabetical order. The...

THIS IS FOR PYTHON CODE

Given 3 words, print the three words in alphabetical order. The program MUST use only if statements.

For example, if the words are:

Jessi Anna and Fred

The program would print:

Anna Fred Jessi

Homework Answers

Answer #1
s = input().split()
a = s[0]
b = s[1]
c = s[2]
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="")

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
I am trying to print an essay in my python code but the words keep getting...
I am trying to print an essay in my python code but the words keep getting cut over two lines. How can i fix this using python code so that it is formatted nicely? thanks
Write a python code to print (any given file) file as a csv format by using...
Write a python code to print (any given file) file as a csv format by using MRJob only. code must be able to run stand-alone MRJob application. For submission to your work: Your final hand should be a single file name BDM.py that takes exactly one arguments for the input path. output will be handled through redirection. Sample run: python BDM.py sample.csv > output.csv
python code Write the function definition for a function which accepts one value from the main...
python code Write the function definition for a function which accepts one value from the main program and prints three times the number that is sent to it. For example, if the program sent 8, the function would print 24.
Use python code to solve IVP. Code must print both general and particular solutions. Please paste...
Use python code to solve IVP. Code must print both general and particular solutions. Please paste full python code for your answer. IVP: y′=(5x^2)(y^2)+(125x^2), y(−7π)=10 Below is an example of code for the problem 7x″−3x′−57x=0, x(2π)=9, x′(−π)=5exp(3) : from sympy import * y = symbols('y') x = Function('x') x = dsolve(7*diff(x(y),y,2)-3*diff(x(y),y)-57*x(y),x(y)) print('The general solution is: ',x,'.',sep='') x = x.rhs xp = diff(x,y) y0, y0p = 2*pi, -pi x0, x0p = 9, 5*exp(3) x0LHS, x0pLHS = x.subs(y,y0) - x0, xp.subs(y,y0p) -...
PYTHON The following code implements this algorithm to sort a list of numbers in ascending order....
PYTHON The following code implements this algorithm to sort a list of numbers in ascending order. But some code is missing as indicated by '?'. def sort_in_place(list_num): for i in range(?): for j in range(?): if ?: temp = list_num[j] list_num[j] = list_num[i] list_num[i] = temp my_list = [23,1,45,20,13,-34] sort_in_place(my_list) print(my_list) Modify the three lines of code in the program below so that the output is [-34, 1, 13, 20, 23, 45]
Using the code as an example, explain why Python is a fixed format programming language. Describe...
Using the code as an example, explain why Python is a fixed format programming language. Describe what would be output for each of the print statements in the code listing.- Given the difference in output, explain the different roles of readLine(), readLines(), and read() functions. with open("rainfall.txt","r") as inFile:    aLine = inFile.readLine() with open("rainfall.txt", "r") as inFile:   lineList = inFile.readLines() with open("rainfall.txt", "r") as inFile:   fileString = inFile.read()) print(aLine) print(lineList) print(fileString)
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
5.Write pseudocode for the algorithm using iteration (looping) and make a flow chart and python code...
5.Write pseudocode for the algorithm using iteration (looping) and make a flow chart and python code from your pseudocode. Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. For example given 3 the algorithm will print 14 (because 1 + 4 + 9 =14) You can use multiplication denoted as * in your solution and you do not have to define it (For example. 3*3=9) For...
Use the Python programming language to complete below (I need the New Answer for this, and...
Use the Python programming language to complete below (I need the New Answer for this, and please provide the screenshot of the source code. Thank you!): Write a program to input an uncertain string S of words and space/tab Remove space/tab in S Remove identical words Sort all words in the order of a-z Print the output strings Example: Input String: "hello world and practice makes perfect and hello world again" Output String: "again and hello makes perfect practice world"...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT