Re: Trying to figure out the data type from the code snippet

2019-01-29 Thread DL Neil

On 30/01/19 5:12 PM, Cameron Simpson wrote:

On 30Jan2019 04:24, Chupo  wrote:

I am trying to figure out what data type is assigned to variable p in
this code snippet:

for p in game.players.passing():
   print p, p.team, p.passing_att, p.passer_rating()


Well, Python comes with a type() builtin function:

  print type(p)



Alternately/additionally, if you ask help(p), it will reveal-all about 
the "class" (of which p is an "instance") - including some answers to 
your second question (and perhaps others which logically follow-on).


If these terms are unfamiliar to you, then 'the manual' reference is 
https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes 
(although from the code above, it would appear that you are looking at 
Python 2.n!). There are plenty of other tutorials available. 
Additionally, Coursera has announced a course starting this week 
(U.Michigan), in Python and its classes - which can be audited for $free 
or used to obtain some sort of certification...


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to figure out the data type from the code snippet

2019-01-29 Thread Cameron Simpson

On 30Jan2019 04:24, Chupo  wrote:

I am trying to figure out what data type is assigned to variable p in
this code snippet:

for p in game.players.passing():
   print p, p.team, p.passing_att, p.passer_rating()


Well, Python comes with a type() builtin function:

 print type(p)


Results:

R.Wilson SEA 29 55.7
J.Ryan SEA 1 158.3
A.Rodgers GB 34 55.8

https://stackoverflow.com/q/28056171/1324175

If p is a string ('print p' prints names of the players) then how is
possible to access p.something?


Well, if p is just a string, then you can't: strings don't have the 
attributes (".something") you're using. Thereofre p is not a string. (It 
_could_ be a subtype of str, but that is pretty unlikely.


What you're probably wanting to know is that the print statement calls 
str(x) for every "x" which it is asked to print, and that "p" has a 
__str__ method returning the "R.Wilson" string (etc). All object's have 
an __str__ method, and for "p" it has been defined to produce what looks 
like a player's name.



If p is an object, then how can p return a string?


"p" is definitely an object: all values in Python are objects.

"p" doesn't return a string, it returns "p".

However, "print" actually prints "str(p)". So it is call's p's __str__ 
method to get a string to print out.


Think of it this way: print's purpose it to print things out, and it 
prints to the output which is text. You can only write strings to text, 
so print converts _everything_ it is given to a string. That "55.7" in 
your output: that is a string representing a floating point value.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Trying to figure out the data type from the code snippet

2019-01-29 Thread Chupo via Python-list
I am trying to figure out what data type is assigned to variable p in 
this code snippet:

for p in game.players.passing():
print p, p.team, p.passing_att, p.passer_rating()

Results:

R.Wilson SEA 29 55.7
J.Ryan SEA 1 158.3
A.Rodgers GB 34 55.8

https://stackoverflow.com/q/28056171/1324175

If p is a string ('print p' prints names of the players) then how is 
possible to access p.something?

If p is an object, then how can p return a string?
-- 
Let There Be Light
Custom LED driveri prema specifikacijama
http://tinyurl.com/customleddriver

Chupo
-- 
https://mail.python.org/mailman/listinfo/python-list


The power of three, sort of

2019-01-29 Thread Avi Gross
I have chosen to stay out of the discussion as it clearly was a TEACHING
example where giving an ANSWER is not the point.

 

So I would like to add some thought without a detailed answer for the boring
way some are trying to steer an answer for. They are probably right that the
instructor wants the students to learn that way.

 

My understanding is the lesson was in how to use the IF command on exactly
three numbers to get the maximum, or perhaps both the maximum and minimum.

 

If this was not for school but the real world, the trivial answer would be
to use max() or min() or perhaps a minmax() that returns a tuple. Or, you
could sort() and choose the first and/or last. 

 

All the above are easy and expand well to any number of N items.

 

My second thought was to do it in one of several standard methods with
nested IF/ELSE statements perhaps using an ELIF. It would produce six (or
perhaps more)  branches and each of them would set any of  a/b/c to be the
maximum. A second complete set would invert some of the > or >= symbols to
get the minimum.

 

But that seems quite long and complicated and I will not show it as we keep
waiting for the student to solve it and then show it so any other students
could copy it!

 

Since there are 3! Possible combinations (albeit if some numbers are the
same, sort of less) a brute force method seems preferable as in:

 

if (a >= b >= c): max = a

.

if (c >= b >= a): max = c

 

That seems wasteful in so many ways and can be shortened perhaps to:

 

if (a >= b >= c): max = a

elif (b >= a >= c): max = b

.

else: max = c

 

Again, six known combinations and fewer tests on average.

 

Another variation is arguably even easier to think about.

 

max, min = float('-inf'), float('inf')

if a > max: max = a

.

if c > max: max = c

# repeat for min using <

 

No nesting and I assume within the allowed rules.

 

The latter makes you wonder about using the one (perhaps two or three) line
version:

 

a, b, c = int(input("first: ")), int(input("second: ")),
int(input("last: "))

max = a if (a>=b and a>=c) else (b if (b>=a and b>=c) else c)

print("max = %d" % max)

 

Again, fairly simple but using a ternary and nested version of if.

 

Results:

 

first: 5

second: 10

last: 7

max = 10

 

first: 5

second: 10

last: 10

max = 10

 

Not saying this is a charmed version using the power of three but I wonder
what kind of answers the instructor expects. I mean you can trivially write
more versions including iterative ones where you unpack the input into a
tuple or list and iterate on it or where you use a function for recursion or
create an object you keep adding to that maintains the biggest so far and on
and on. You can even do calculations after the first two inputs and then use
that to compare after the third input. There is no one right answer even for
simplified methods.

 

If I get to teach this, I probably would not tell them there are many ways
but might give extra credit for those who innovate or make it somewhat more
efficient looking but perhaps penalize solutions that others might not
easily understand.

 

Ending comment. Every use of the ellipsis above should not be typed in and
represent missing lines that need to be added but are not being specified.
The one liner does work and there are more nested variations of that you can
use. My thoughts apply well beyond this simple example to the question of
how you define a problem so that people use only what they know so far and
are taught how to use it even if they may not ever actually need to use it
again.

 

 

 

 

 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python stopped installing packages

2019-01-29 Thread Ian Clark
according to https://pypi.org/project/discord.py/ Discord.py only supports
3.4 and 3.5

On Tue, Jan 29, 2019 at 4:52 PM Hamish Allen <101929...@gmail.com> wrote:

> Hi,
>
> Recently I’ve been trying to code a Discord bot in Python 3.6.2, then I
> realised that some features of discord.py were only available in Python
> 3.7+ (as seen here on the right near the top
> https://docs.python.org/3/library/asyncio.html), so I downloaded 3.7.2.
> After correctly changing the environmental variables to have Python 3.7.2
> before Python 3.6.2, I tried installing (for installing I was using cmd
> ‘pip install discord.py’, I’m not aware of any other way to install
> packages) discord.py onto Python 3.7.2, but after a few seconds there would
> be a whole page of red error text (attached), then it would say
> successfully installed. I tried importing it in code, but it would return
> errors implying it was incorrectly installed. I asked one of my friends for
> some help. He suggested uninstalling Python 3.6.2 and 3.7.2 and
> reinstalling Python 3.7.2. I thought this was a pretty good idea so I did
> it. Discord.py still refuses to be installed. I tried installing some of
> the packages I had in 3.6.2, but they had the same sort of problem. I’ve
> tried running the installer to repair the files, but that didn’t work. I
> would appreciate if you could help me. I got discord.py from here:
> https://github.com/Rapptz/discord.py I’ve tried the 3 commands in the
> Installing section and I’ve tried pip install discord.py.
>
> Thanks,
> Hamish
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
which version of Python? I get Syntax error on 3.7.1

On Tue, Jan 29, 2019 at 12:37 PM Adrian Ordona 
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  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.schach...@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 
>> Sent: Tuesday, January 29, 2019 2:52 PM
>> To: Schachner, Joseph 
>> Cc: Dan Sommers <2qdxy4rzwzuui...@potatochowder.com>;
>> python-list@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.schach...@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> >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
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Python stopped installing packages

2019-01-29 Thread Hamish Allen
Hi,

Recently I’ve been trying to code a Discord bot in Python 3.6.2, then I 
realised that some features of discord.py were only available in Python 3.7+ 
(as seen here on the right near the top 
https://docs.python.org/3/library/asyncio.html), so I downloaded 3.7.2. After 
correctly changing the environmental variables to have Python 3.7.2 before 
Python 3.6.2, I tried installing (for installing I was using cmd ‘pip install 
discord.py’, I’m not aware of any other way to install packages) discord.py 
onto Python 3.7.2, but after a few seconds there would be a whole page of red 
error text (attached), then it would say successfully installed. I tried 
importing it in code, but it would return errors implying it was incorrectly 
installed. I asked one of my friends for some help. He suggested uninstalling 
Python 3.6.2 and 3.7.2 and reinstalling Python 3.7.2. I thought this was a 
pretty good idea so I did it. Discord.py still refuses to be installed. I tried 
installing some of the packages I had in 3.6.2, but they had the same sort of 
problem. I’ve tried running the installer to repair the files, but that didn’t 
work. I would appreciate if you could help me. I got discord.py from here: 
https://github.com/Rapptz/discord.py I’ve tried the 3 commands in the 
Installing section and I’ve tried pip install discord.py.

Thanks,
Hamish 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
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.schach...@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 
> Sent: Tuesday, January 29, 2019 2:52 PM
> To: Schachner, Joseph 
> Cc: Dan Sommers <2qdxy4rzwzuui...@potatochowder.com>;
> python-list@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.schach...@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 >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
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in Installing version 3.7.2(64 bit)

2019-01-29 Thread Ian Clark
back in my day we had to show our professors errors on punchcard! and we
liked it

On Sun, Jan 27, 2019 at 11:51 AM Terry Reedy  wrote:

> On 1/26/2019 6:24 AM, Vrinda Bansal wrote:
> > Dear Sir/Madam,
> >
> > After Installation of the version 3.7.2(64 bit) in Windows 8 when I run
> the
> > program it gives an error. Screenshot of the error is attached below.
>
> Nope.  This is text only mail list.  Images are tossed.  You must copy
> and paste.
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
threw this together, let me know what you think


num_list=[]
name_list =
['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth']
name_it = name_list.pop(0)

while len(num_list) < 3:
 try:
  num_list.append( int( input(f"Insert the {name_it} number: ")))

 except ValueError:
  print('Not a number, try again!')
 else:
  name_it = name_list.pop(0)

print(f"Max number is: {sorted(num_list)[-1]}")

On Mon, Jan 28, 2019 at 1:58 AM Frank Millman  wrote:

> "^Bart"  wrote in message news:q2mghh$ah6$1...@gioia.aioe.org...
> >
> > > 1. The last two lines appear to be indented under the 'if number3 < '
> > > line. I think you want them to be unindented so that they run every
> > > time.
> >
> > I'm sorry but I didn't completely understand what you wrote about the
> last
> > two lines, please could you write how my code could be fixed?
> >
>
> The last four lines of your program look like this -
>
> if number3 < number2 and number3 < number1:
>  numbermin = number3
>
>  print("Number min is: ",numbermin)
>
>  numbermiddle = (number1+number2+number3)-(numbermax+numbermin)
>
>  print("Number middle is: ",numbermiddle)
>
> The last three lines all fall under the 'if number3 < number2' line, so
> they
> will only be executed if that line evaluates to True.
>
> I think that you want the last two lines to be executed every time. If so,
> they should be lined up underneath the 'if', not the 'print'.
>
> >
> > > if a == 1:
> > > do something
> > > elif a == 2:
> > > do something else
> >
> > Finally I understood the differences between if and elif! Lol! :D
> >
>
> It is actually short for 'else if', but I guess it is not obvious if you
> have not seen it before!
>
> Frank
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Ian Clark
Like this?

num_max = 0
num_index = 0
name_list =
['first','second','third','fourth','fifth','sixth','seventh','eighth','ninth','tenth']
name_it = name_list.pop(0)


while num_index <3:
 try:
  num_list = int( input(f"Insert the {name_it} number: "))

 except ValueError:
  print('Not a number, try again!')
 else:
  num_index += 1
  if num_list > num_max:
   num_max = num_list
  name_it = name_list.pop(0)

print(f"Max number is: {num_max}")

On Tue, Jan 29, 2019 at 1:26 PM Chris Angelico  wrote:

> On Wed, Jan 30, 2019 at 8:20 AM Bob van der Poel  wrote:
> > Isn't the easiest way to do this is:
> >
> >  sorted( [n1,n2,n3] )[-1]
> >
> > to get the largest value?
>
> >>> help(max)
>
> But the point of this exercise is not to use sorted() or max().
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Chris Angelico
On Wed, Jan 30, 2019 at 8:20 AM Bob van der Poel  wrote:
> Isn't the easiest way to do this is:
>
>  sorted( [n1,n2,n3] )[-1]
>
> to get the largest value?

>>> help(max)

But the point of this exercise is not to use sorted() or max().

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Bob van der Poel
On Tue, Jan 29, 2019 at 12:52 PM Adrian Ordona 
wrote:

> 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.schach...@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 > >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
>

Isn't the easiest way to do this is:

 sorted( [n1,n2,n3] )[-1]

to get the largest value?

-- 

 Listen to my FREE CD at http://www.mellowood.ca/music/cedars 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: b...@mellowood.ca
WWW:   http://www.mellowood.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Adrian Ordona
The code actually works just the way i copy and pasted

Sent from my iPhone

> On Jan 29, 2019, at 12:34, Ian Clark  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 
>>  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 
>> Sent: Tuesday, January 29, 2019 2:52 PM
>> To: Schachner, Joseph 
>> Cc: Dan Sommers <2qdxy4rzwzuui...@potatochowder.com>; python-list@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 
>> mailto:joseph.schach...@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> >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
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Exercize to understand from three numbers which is more high

2019-01-29 Thread Schachner, Joseph
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 
Sent: Tuesday, January 29, 2019 2:52 PM
To: Schachner, Joseph 
Cc: Dan Sommers <2qdxy4rzwzuui...@potatochowder.com>; python-list@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 
mailto:joseph.schach...@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 N1MaxNum = 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


Re: Problem in Installing version 3.7.2(64 bit)

2019-01-29 Thread songbird
Anssi Saari wrote:
> Terry Reedy  writes:
>> On 1/26/2019 6:24 AM, Vrinda Bansal wrote:
>>> Dear Sir/Madam,
>>>
>>> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the
>>> program it gives an error. Screenshot of the error is attached below.
>>
>> Nope.  This is text only mail list.  Images are tossed.  You must copy
>> and paste.
>
> Just curious, but wouldn't it be better to just reject messages with
> attachments instead of silent removal? I suppose the end result is
> mostly the same for the person asking but the rest of us would be
> spared.

  my understanding is that this list is actually 
several combined services (i'm not sure how the
mailing list operates or how it filters or rejects
things) and then there is the usenet list comp.lang.python
(which is how i see articles and replies).

  usenet has usually been a text only service unless
you have a specific binary group (some usenet servers
have them and others don't).

  asking the person to upload the image to someplace
else and provide a link to the image would be a thing
for the FAQ if there were one for either or both of 
the e-mail list service provider or the usenet group.


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Adrian Ordona
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.schach...@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 >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


RE: Exercize to understand from three numbers which is more high

2019-01-29 Thread Schachner, Joseph
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    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


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread MRAB

On 2019-01-29 16:02, Dan Sommers wrote:

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

No.  Assuing that you meant to include colons where I think
you did, what if (N1, N2, N3) == (5, 4, 6)?


And it's still longer and more complicated than it needs to be.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Dan Sommers

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

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


Re: How do I get a python program to work on my phone?

2019-01-29 Thread Michael Torrie
On 2019-01-29 8:44 a.m., Michael Torrie wrote:
> There have been some Python to javascript compilers, or implementations
> of Python in Javascript.  So maybe it's possible to make a hybrid app
> using Python.

Here's an interesting project that might work with some hybrid app
development frameworks:

https://github.com/QQuick/Transcrypt

Translates Python 3.7 code to Javascript, with an emphasis on
integration with javascript libraries for web development.  Interesting.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I get a python program to work on my phone?

2019-01-29 Thread Michael Torrie
On 2019-01-29 5:52 a.m., Bob Gailer wrote:
> An interesting alternatives to create a simple web page to run in the
> phone's browser. If you don't already have a server on the web you can rent
> one from secure dragon for as low as $12 a year. Install websocketd and
> python. Websocketd lets you do all sorts of interesting things such as
> serve static pages, CGI programs, and use websockets. Websockets requires a
> little bit of JavaScript but makes the interaction between a browser page
> and a Python program on the server ridiculously easy. Much easier than
> Ajax. Feel free to ask for more information. I posted a Python program on
> the websocketd website that shows how to do the server side of websockets
> communication.

If you're willing to forego Python and embrace Javascript, there are
many options, some are fairly easy to get into.  Adobe has their
PhoneGap system (http://phonegap.com).  There are others.  They call
these hybrid apps.

Recently I made a small app using V-Play which is based on QtQuick.  Was
super easy.  The most amount of time was spent figuring out QML GUI
layout.  Straight QtQuick works decently well too, using the QtCreator IDE.

There have been some Python to javascript compilers, or implementations
of Python in Javascript.  So maybe it's possible to make a hybrid app
using Python.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Jack Dangler


On 1/27/19 7:34 AM, Frank Millman wrote:

"^Bart" wrote in message news:q2k1kk$1anf$1...@gioia.aioe.org...


>    You need to do this exercize just by using if, elif and else,
>    but in the quotation above, you use "=".

We can use > < and =

Now I wrote:

number1 = int( input("Insert the first number: "))

number2 = int( input("Insert the second number: "))

number3 = int( input("Insert the third number: "))



[snip stuff that doesn’t work]



But it doesn't work... :\



You have got to a starting point - you have three numbers. Good.

Where do you do go from here?

I would start with two of the numbers, and work out which one is higher.

Once you know that, you can compare that one with the third number, 
and work out which one is higher.


From that, you can work out which one is the highest of all three.

Then you can apply the same logic to work out which is the lowest.

Give that a go, and come back here if you get stuck.

Frank Millman


Frank - The OP didn't appear to need to 'sort' the inputs, but only to 
solve for the highest value of the three using limited arithmetic 
operators. I like your text walkthrough. It should give the OP enough 
to go on. I only supplied a linear solution because I am not sure why 
this would be a struggle.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Jack Dangler


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 N1https://mail.python.org/mailman/listinfo/python-list


Re: How do I get a python program to work on my phone?

2019-01-29 Thread Bob Gailer
kivy has a very steep learning curve. The easy way to use kivy is to
install the kivy launcher app which then lets you run a Python program and
access the kivy widgets. If you really want to dive into kivy I will send
you a presentation I gave on kivy. After a lot of work I did manage to
create an install an app.

An interesting alternatives to create a simple web page to run in the
phone's browser. If you don't already have a server on the web you can rent
one from secure dragon for as low as $12 a year. Install websocketd and
python. Websocketd lets you do all sorts of interesting things such as
serve static pages, CGI programs, and use websockets. Websockets requires a
little bit of JavaScript but makes the interaction between a browser page
and a Python program on the server ridiculously easy. Much easier than
Ajax. Feel free to ask for more information. I posted a Python program on
the websocketd website that shows how to do the server side of websockets
communication.

Bob Gailer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in Installing version 3.7.2(64 bit)

2019-01-29 Thread Anssi Saari
Terry Reedy  writes:

> On 1/26/2019 6:24 AM, Vrinda Bansal wrote:
>> Dear Sir/Madam,
>>
>> After Installation of the version 3.7.2(64 bit) in Windows 8 when I run the
>> program it gives an error. Screenshot of the error is attached below.
>
> Nope.  This is text only mail list.  Images are tossed.  You must copy
> and paste.

Just curious, but wouldn't it be better to just reject messages with
attachments instead of silent removal? I suppose the end result is
mostly the same for the person asking but the rest of us would be
spared.

-- 
https://mail.python.org/mailman/listinfo/python-list