Exercize to understand from three numbers which is more high
Jack Dangler
tdldev at gmail.com
Tue Jan 29 10:27:48 EST 2019
On 1/27/19 5:19 AM, ^Bart wrote:
>> In my experience based on decades of writing programs...
>>
>> 1. The assignment/exercise/problem should be a write a function with
>> a particular signature. So first decide on the signature.
>>
>> def max3(n1, n2, n3):
>> "Return the max of the three inputs."
>> return None # To be replaced.
>
> I need to do this exercize just by using if, elif and else, in the
> next lesson we'll discuss other kind of rules! :)
>
> So I need to insert three int numbers and I should show which is the
> high, the middle and the min.
>
> # Exercize 305
>
> number1 = int( input("Insert the first number: "))
>
> number2 = int( input("Insert the second number: "))
>
> number3 = int( input("Insert the third number: "))
>
> numbermax = number1
>
> numbermiddle = number2
>
> numbermin = number3
>
> if number2 > number1 and number2 > number3:
> numbermax = number2
>
> if number3 < number2 and number3 < number1:
> numbermin = number3
>
> else:
> numbermiddle is number1
>
> print("Number max is: ",numbermax, "Number middle is;
> ",numbermiddle,"Number min is: ", numbermin)
>
> if number2 < number1 and number2 < number3:
> numbermin = number2
>
> if number3 > number2 and number3 > number1:
> numbermax = number3
>
> else:
> numbermiddle is number2
>
> print("Number min is: ",numbermin)
>
> I don't understand how could I fix it :\
wow. Seems like a lot going on. You have 3 ints and need to determine
the max? Doesn't this work?
N1, N2, N3
if N1>N2
if N1>N3
MaxNum = N1
elif N2>N3
MaxNum = N2
elif N1<N3
MaxNum = N3
More information about the Python-list
mailing list