Re: [Tutor] Numpy documentation

2018-10-04 Thread Steven D'Aprano
Hi Roger,

My comments below, below yours.

On Thu, Oct 04, 2018 at 12:02:01PM -0700, Roger Lea Scherer wrote:

[...]
>  In the example pictured below, the array has 2 axes. The first axis has a
> length of 2, the second axis has a length of 3.
> [[ 1., 0., 0.],
>  [ 0., 1., 2.]]
> 
> (I think) I understand the 2 axes. [1,0,0] (I'm lazy and don't want to type
> the periods) is one axis and [0,1,2] is the second axis.

You can copy and paste text to avoid extra typing.

You seem to be are thinking along the lines of axles in a car, where the 
two axles run parallel:

Axle one: -
Axle two: -


You should think of axes of a graph, which run perpendicular to each 
other, like the lines of a plus sign + or cross.

So the array:

[[ 1., 0., 0.],
 [ 0., 1., 2.]]

is two dimensional, with 2 rows and 3 columns. In mathematics, we 
would call it a 2x3 matrix; in programming, it would be a 2x3 array.

Axis one (rows): length 2
Axis two (columns): length 3


Regards,



-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Numpy documentation

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 20:02, Roger Lea Scherer wrote:

>  In the example pictured below, the array has 2 axes. The first axis has a
> length of 2, the second axis has a length of 3.
> [[ 1., 0., 0.],
>  [ 0., 1., 2.]]
> 
> (I think) I understand the 2 axes. [1,0,0] (I'm lazy and don't want to type
> the periods) is one axis and [0,1,2] is the second axis. 

Nope. Its the other way round. The first axis is
the "column" of two rows. Hence length 2.
The second axis is the row with 3 elements in each.

If you look at it as a table you can access the
elements using x,y coordinates. The x coordinate
(being first) denotes which row is indicated and
the y axis being second denotes the element within
the row.

> ...But why does the first axis have a length of 2?

Because there are two rows.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Numpy documentation

2018-10-04 Thread Roger Lea Scherer
I truly don't think I'm this stupid, but I can't even understand the fourth
paragraph of the numpy documentation.
https://docs.scipy.org/doc/numpy/user/quickstart.html says:

 In the example pictured below, the array has 2 axes. The first axis has a
length of 2, the second axis has a length of 3.
[[ 1., 0., 0.],
 [ 0., 1., 2.]]

(I think) I understand the 2 axes. [1,0,0] (I'm lazy and don't want to type
the periods) is one axis and [0,1,2] is the second axis. But then things
get goofy. The first axis has a length of 2. Is that because [1,0,0] and
[0,1,2] are counted as one axis? (I think) I understand the second axis has
a length of 3 because there are 3 elements within the [0,1,2] axis. Is that
correct? But why does the first axis have a length of 2? Because the second
zero doesn't count? Did they change the example and forgot to change the
text?

Thank you for your help as always.


-- 
Roger Lea Scherer
623.255.7719

  *Strengths:*
   Input, Strategic,
Responsibility,

Learner, Ideation
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 15:15, Roger B. Atkins wrote:
> That's very helpful, thanks. After reading the Tutor information last
> night, I wrote a little program I named sysinfo. The code run line by
> line in a Spyder console yields:
> 
> In [3]: sys.path
> Out[3]:
> ['',
>  'C:\\Users\\rba21\\Anaconda3\\python36.zip',
>  'C:\\Users\\rba21\\Anaconda3\\DLLs',
>  'C:\\Users\\rba21\\Anaconda3\\lib',
>  'C:\\Users\\rba21\\Anaconda3',
>  'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages',

Note that the interesting bit is what it looks like outside
of Spyder. We know it works OK within Spyder it's what
gets defined outside Spyder that matters.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Roger B. Atkins
That's very helpful, thanks. After reading the Tutor information last
night, I wrote a little program I named sysinfo. The code run line by
line in a Spyder console yields:

In [3]: sys.path
Out[3]:
['',
 'C:\\Users\\rba21\\Anaconda3\\python36.zip',
 'C:\\Users\\rba21\\Anaconda3\\DLLs',
 'C:\\Users\\rba21\\Anaconda3\\lib',
 'C:\\Users\\rba21\\Anaconda3',
 'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages',
 'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages\\win32',
 'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages\\win32\\lib',
 'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages\\Pythonwin',
 'C:\\Users\\rba21\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
 'C:\\Users\\rba21\\.ipython']

In [4]: sys.version
Out[4]: '3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC
v.1900 64 bit (AMD64)]'

In [5]: sys.platform
Out[5]: 'win32'

I'll have to do more research to figure out which folders I need to
add given that '\site-packages'
is already included, but at least I won't be looking at the wrong path variable.
On Thu, Oct 4, 2018 at 6:54 AM Mats Wichmann  wrote:
>
> On 10/03/2018 09:20 PM, Roger B. Atkins wrote:
> > System:  Windows 10, Anaconda, Python 3, Spyder3
> >
> > Problem: Running programs that import requests, pyperclip, bs4 and/or
> > other modules from 3rd party packages works fine within Spyder IDE,
> > but not from command line, or Win/R. The error message indicates no
> > such module. Therefore, my programs crash at the import statement. In
> > contrast, programs using built in modules work fine everywhere.
> > Questions: Which file needs to be found? Is this a path problem?
> >
> > Efforts to solve problem:  After making sure I had correctly typed the
> > module names, my second guess was that it is a path problem, so I used
> > win explorer to locate the module files. I also went to the command
> > line and used "pip show modname".
> > The search using win explorer revealed module files in multiple
> > directories, so part of the problem may be that I don't know which
> > file the import statement needs to be able to find.
> > Based on results using pip show modname, the modules were installed in:
> > Anaconda3\lib\site-packages.
> > In fact, as shown in Win Explorer, they are in sub folders under
> > \site-packages, and there are 'regular' py files as well as compiled
> > files. (I'm a beginner, and thought Python was interpreted?)
> >
> > I changed my system path variable to include:
> > C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message
> > C:\Users\rba21\Anaconda3\lib\site-packages\pyperclip  # Result: same
> > error message
> > I tried adding the sub folders down to __pycache__  but got the same
> > error message.
> >
> > I did some web searches, but didn't find anything that enabled me to
> > fix the problem.
>
> Write this simple program and run it from the "command line":
>
> import sys
> print(sys.path)
>
> those are the places Python will look for modules when importing. you
> can add to sys.path in your program, or if you define PYTHONPATH, its
> contents will show up in sys.path.
>
> if you now do the same thing in a program running inside Spyder, you'll
> probably see differences in sys.path.
>
> as Alan said, the system/user environment paths have nothing to do with
> Python's module importing.
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Roger B. Atkins
Thanks! That helps. I'll have to go back to the drawing board, but
you've put me on the right "path".
On Thu, Oct 4, 2018 at 12:47 AM Alan Gauld via Tutor  wrote:
>
> On 04/10/18 04:20, Roger B. Atkins wrote:
> > System:  Windows 10, Anaconda, Python 3, Spyder3
> >
>
> > I changed my system path variable to include:
> > C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message
>
> When you say the "system path" do you mean the PYTHONPATH
> variable? It's PYTHONPATH not PATH that determines where
> Python looks for modules...
>
> Just a thought.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Mats Wichmann
On 10/03/2018 09:20 PM, Roger B. Atkins wrote:
> System:  Windows 10, Anaconda, Python 3, Spyder3
> 
> Problem: Running programs that import requests, pyperclip, bs4 and/or
> other modules from 3rd party packages works fine within Spyder IDE,
> but not from command line, or Win/R. The error message indicates no
> such module. Therefore, my programs crash at the import statement. In
> contrast, programs using built in modules work fine everywhere.
> Questions: Which file needs to be found? Is this a path problem?
> 
> Efforts to solve problem:  After making sure I had correctly typed the
> module names, my second guess was that it is a path problem, so I used
> win explorer to locate the module files. I also went to the command
> line and used "pip show modname".
> The search using win explorer revealed module files in multiple
> directories, so part of the problem may be that I don't know which
> file the import statement needs to be able to find.
> Based on results using pip show modname, the modules were installed in:
> Anaconda3\lib\site-packages.
> In fact, as shown in Win Explorer, they are in sub folders under
> \site-packages, and there are 'regular' py files as well as compiled
> files. (I'm a beginner, and thought Python was interpreted?)
> 
> I changed my system path variable to include:
> C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message
> C:\Users\rba21\Anaconda3\lib\site-packages\pyperclip  # Result: same
> error message
> I tried adding the sub folders down to __pycache__  but got the same
> error message.
> 
> I did some web searches, but didn't find anything that enabled me to
> fix the problem.

Write this simple program and run it from the "command line":

import sys
print(sys.path)

those are the places Python will look for modules when importing. you
can add to sys.path in your program, or if you define PYTHONPATH, its
contents will show up in sys.path.

if you now do the same thing in a program running inside Spyder, you'll
probably see differences in sys.path.

as Alan said, the system/user environment paths have nothing to do with
Python's module importing.




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] coding problem

2018-10-04 Thread Steven D'Aprano
On Wed, Oct 03, 2018 at 11:22:45PM -0500, ramanpreet baidwan wrote:

> Can anyone tell me how to code to display permutations in a table for 
> all values of z=x^2+y by getting input from user for range of x and y?

Yes. Use a text editor to write your code in a text file. When you save 
the file, use .py as the file extension, not .txt.

Do you know how to program? It sounds like you are doing homework. You 
should start by showing us the code you have already written. If you 
have written no code at all, tell us what you know how to do and ask 
*specific* questions.

Terrible question: "Can somebody do my home work for me?"

Bad question: "How do I write this code?"

Good question: "How do I write a for loop?"

Excellent question: "I tried to write a for-loop from 1 to 5, but it 
only went to 4. Here is my code. What did I do wrong?"

If you ask excellent questions, we can give you excellent answers.

Do you know how to use print? Do you know how to get input from the 
user? Can you write a for-loop over a range from x to y?


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] coding problem

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 05:22, ramanpreet baidwan wrote:
> Can anyone tell me how to code to display permutations in a table 
> for all values of z=x^2+y by getting input from user for range of x and y?

There are several problems with your question.
First it sounds suspiciously like homework and
we won't do that for you.
(Although we will give you some pointers)

Second permutations sounds like the wrong word.
I suspect you just want all the solutions for
z displayed in a table against x,y pairs.
Is that correct?

Next, taken literally, the problem is impossible
since x,y have an infinite number of values. So to
have any chance you need to define the quantum
steps between x and y - integers, 0.1, 0.01, etc.
Otherwise you need to draw a graphical representation
rather than use a table.

Finally, its not clear what you are asking for help with.
Do you not know how to present output in a table format?
Do you not know how to calculate z?
Do you not know how to prompt the user for inputs?
Do you not know how to generate the x,y values from
the users input?

It's best if you can write some code then send us
that along with the output (including full error
message, if any). Then ask a specific question about
what is going wrong and how you want us to help.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] coding problem

2018-10-04 Thread Mark Lawrence

On 04/10/18 05:22, ramanpreet baidwan wrote:

Can anyone tell me how to code to display permutations in a table for all 
values of z=x^2+y by getting input from user for range of x and y?



Sorry but no as we do not do homework.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 04:20, Roger B. Atkins wrote:
> System:  Windows 10, Anaconda, Python 3, Spyder3
> 

> I changed my system path variable to include:
> C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message

When you say the "system path" do you mean the PYTHONPATH
variable? It's PYTHONPATH not PATH that determines where
Python looks for modules...

Just a thought.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] coding problem

2018-10-04 Thread ramanpreet baidwan
Can anyone tell me how to code to display permutations in a table for all 
values of z=x^2+y by getting input from user for range of x and y?

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Roger B. Atkins
System:  Windows 10, Anaconda, Python 3, Spyder3

Problem: Running programs that import requests, pyperclip, bs4 and/or
other modules from 3rd party packages works fine within Spyder IDE,
but not from command line, or Win/R. The error message indicates no
such module. Therefore, my programs crash at the import statement. In
contrast, programs using built in modules work fine everywhere.
Questions: Which file needs to be found? Is this a path problem?

Efforts to solve problem:  After making sure I had correctly typed the
module names, my second guess was that it is a path problem, so I used
win explorer to locate the module files. I also went to the command
line and used "pip show modname".
The search using win explorer revealed module files in multiple
directories, so part of the problem may be that I don't know which
file the import statement needs to be able to find.
Based on results using pip show modname, the modules were installed in:
Anaconda3\lib\site-packages.
In fact, as shown in Win Explorer, they are in sub folders under
\site-packages, and there are 'regular' py files as well as compiled
files. (I'm a beginner, and thought Python was interpreted?)

I changed my system path variable to include:
C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message
C:\Users\rba21\Anaconda3\lib\site-packages\pyperclip  # Result: same
error message
I tried adding the sub folders down to __pycache__  but got the same
error message.

I did some web searches, but didn't find anything that enabled me to
fix the problem.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor