[Tutor] computation library
Alan Gauld
alan.gauld at btinternet.com
Fri May 29 02:15:37 CEST 2015
On 28/05/15 23:26, Yongnuan Liu wrote:
> I am new to Python. I just downloaded Python 2.7.10. I am very frustrated
> on starting programming.
Welcome.
Don't be surprised at being frustrated, many people find that
when starting out. We are all so used to computers doing
very smart things that its often a surprise to discover just
how dumb they really are and how much detail is needed
to program them.
> 1. Could someone recommend me a more user friendly python debugging tool?
That depends on what debugging tool you are using now.
For beginners the best debugging tools, by far, are
the print statement and the >>> prompt.
But you can also use an IDE like IDLE or Pythonwin.
They both have more sophisticated (and so more complex)
debuggers.
And then there is Winpdb which is a GUI debugger but
also fairly complex for a beginner.
Finally, there are complex professional tools like
Netbeans and Eclipse that have Python add-ons that
have very powerful debugging tools included. But
they are probably only worthwhile if you already
program in another language and use those tools
there. Most Python programmers, even professionals,
do 90% of their debugging using the >>> prompt and
some print statements!
> 2. Where to download the computing/plotting library, like scipy etc?
There is a repository of modules and packages for
Python called PyPI and a tool called pip which you use
to install things from there. But as a beginner you
almost certainly don't need any of that yet. Python
comes with hundreds of modules as standard that
should do most of the things you need initially.
If you are going to do a lot of mathg/science work then
you should probably install one of the bundled SciPy
distributions such as Anaconda or Canopy. But learn the
basics first, you may find the standard edition does
all you need,
> example, when I input a=sin(30), the error says sin is not defined??
That's right, sin() is a math function so it is defined
in the math module. You need to import math first
then you can access it as math.sin()
if you do
>>> import math
>>> print math.sin( math.radians(30) ) # sin() uses radians not degrees
0.5
Then type
>>> help(math)
......
and you will see all of the functions and constants that
are defined in that module.
You don't say which tutorial you are following but any
reasonable one should include information about using
modules. (For example mine- -see the .sig - has a
topic called 'Modules and Functions'. But even in the
first hands-on topic - Simple Sequences - it introduces
the idea.)
> 3. How to set up variable enviroment before using these libraries?
I'm not sure what you mean by this one.
On any properly installed Python you can import modules
from the standard library without any additional work.
--
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
More information about the Tutor
mailing list