V
V
Veniamin Belousov2018-03-14 08:34:20
Python
Veniamin Belousov, 2018-03-14 08:34:20

Where is the incorrectness of logic - in the program for the output of the largest number?

a, b, c = [input() for _ in range(3)]
if a > b and a > c:
    print(a)
elif b > a and b > c:
    print(b)
elif c > a and c > b:
    print(c)

For example, if I make the numbers 6,1,11 on the input, I will get 6 on the output ... Please don’t talk about sorting functions, it’s also possible with them, but now it’s not necessary)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dvlprjv15, 2018-03-14
@Venuhaha

Logic is all right. Changed the first line to: Then I changed 11 to different variables. In all cases, the program outputs the largest number. It's quite another thing that I don't understand what the code is supposed to do: Please explain.

R
Ruslan., 2018-03-14
@LaRN

You have an error in the program, what will happen if you enter all three identical numbers?
Judging by the code, nothing will be displayed, since in all if the check is strictly for more than.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question