Answer to Question #257415 in Python for pau

Question #257415

Where's the Biggest One?

by CodeChum Admin

We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate the position of the largest among 5 numbers. There are only 4 possible cases for this mission:

- if the largest digit is the first digit, print "Leftmost"

- if the largest digit is the third digit, print "Middle"

- if the largest digit is the last digit, print "Rightmost"

- if none of the above is correct, print "Unknown"

 

Now, show me how far you've understood your lessons!


1
Expert's answer
2021-10-27T16:23:34-0400
n = [int(i) for i in input("Input 5 . separated integers: ").split('.')][:5]
max_value = max(n)
index = n.index(max_value)




if index==0:
 print("Leftmost")




elif index==2:
 print("Middle")
elif index==4:
 print("Rightmost")
else:
 print("Unknown")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog