Exercize to understand from three numbers which is more high

Ian Clark ianhclark510 at gmail.com
Tue Jan 29 16:04:43 EST 2019


which version of Python? I get Syntax error on 3.7.1

On Tue, Jan 29, 2019 at 12:37 PM Adrian Ordona <adrian.ordona at gmail.com>
wrote:

> The code actually works just the way i copy and pasted
>
> Sent from my iPhone
>
> On Jan 29, 2019, at 12:34, Ian Clark <ianhclark510 at gmail.com> wrote:
>
> just the pure number of letters next to parenthesis would cause the Parser
> to error out
>
> On Tue, Jan 29, 2019 at 12:32 PM Schachner, Joseph <
> Joseph.Schachner at teledyne.com> wrote:
>
>> Yes, that works.  Assuming it was correctly formatted when you ran it.
>> The formatting could not possibly be run in a Python interpreter, I think.
>>
>> --- Joseph S.
>>
>> From: Adrian Ordona <adrian.ordona at gmail.com>
>> Sent: Tuesday, January 29, 2019 2:52 PM
>> To: Schachner, Joseph <Joseph.Schachner at Teledyne.com>
>> Cc: Dan Sommers <2QdxY4RzWzUUiLuE at potatochowder.com>;
>> python-list at python.org
>> Subject: Re: Exercize to understand from three numbers which is more high
>>
>> i'm also a beginner reading all the replies helps.
>> i was trying the problem myself and came up with the below code with a
>> users input.
>>
>>
>> num1 = int(input("Enter first number: "))num2 = int(input("Enter second
>> number: "))num3 = int(input("Enter third number: "))if num1 > num2 and num1
>> > num3:    print(num1, " is th max number")elif num2 > num1 and num2 >
>> num3:    print(num2, " is the max number")else:     print(num3, "is the max
>> number")
>>
>> On Tue, Jan 29, 2019 at 1:48 PM Schachner, Joseph <
>> Joseph.Schachner at teledyne.com<mailto:Joseph.Schachner at teledyne.com>>
>> wrote:
>> Explanation: 5 > 4 so it goes into the first if.  5 is not greater than
>> 6, so it does not assign N1 to MaxNum.  The elif (because of the lack of
>> indent) applies to the first if, so nothing further is executed. Nothing
>> has been assigned to MaxNum, so that variable does not exist.  You're
>> right, it does not work.
>>
>> How about this:
>> Mylist = [ N1, N2, N3]
>> Maxnum = N1
>> for value in Mylist:
>>     if value > Maxnum:
>>         Maxnum = value
>> print(Maxnum)
>>
>> Or were lists and for loops excluded from this exercise?
>> --- Joe S.
>>
>> On 1/29/19 9:27 AM, Jack Dangler wrote:
>>
>> > 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
>>
>> No.  Assuing that you meant to include colons where I think you did, what
>> if (N1, N2, N3) == (5, 4, 6)?
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>



More information about the Python-list mailing list