I
I
Ivan2014-11-11 08:50:01
Python
Ivan, 2014-11-11 08:50:01

How to correctly construct a selection by comparison in Python?

You need to make a program that takes three integers as input, and first displays the maximum, then the minimum, after which the remaining number.
With a minimum, a maximum figured out what to do with the rest?

a=int(input())
b=int(input())
c=int(input())
n=max([a, b, c])
m=min([a, b, c])
if a!=n and a!=m:
    g=a
    if b!=n and b!=m:
        g=b
        if c!=n and c!=m:
            g=c
print(n)
print(m)
print(c)

does not work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kyberman, 2014-11-11
@muller_johann

print(c)
- of course does not work, you need to replace it with print (g).
There is another trick:g = a + b + c - n - m

A
Andrey K, 2014-11-11
@mututunus

l = [a,b,c]
l.sort()
print('Max:', l[2])
print('Min:', l[0])
print('Other:', l[1])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question