Discussion:
[Tutor] computation library
Yongnuan Liu
2015-05-28 22:26:26 UTC
Permalink
Hi Everyone,

I am new to Python. I just downloaded Python 2.7.10. I am very frustrated
on starting programming. Here are some questions which I hope you can help
me with?

1. Could someone recommend me a more user friendly python debugging tool?

2. Where to download the computing/plotting library, like scipy etc? For
example, when I input a=sin(30), the error says sin is not defined?? it is
just simple calculation and I cannot do it correctly.

3. How to set up variable enviroment before using these libraries?

Thank you so much for your help. I appreciate it.

Regards,

Yong
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-05-29 00:15:37 UTC
Permalink
Post by Yongnuan Liu
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.
Post by Yongnuan Liu
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!
Post by Yongnuan Liu
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,
Post by Yongnuan Liu
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
Post by Yongnuan Liu
import math
print math.sin( math.radians(30) ) # sin() uses radians not degrees
0.5

Then type
Post by Yongnuan Liu
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.)
Post by Yongnuan Liu
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


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-05-29 01:22:18 UTC
Permalink
Post by Alan Gauld
Post by Yongnuan Liu
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.
Post by Yongnuan Liu
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.
Once you've got the hang of things far better than the print statement
is the logging module
https://docs.python.org/3/library/logging.html#module-logging
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Steven D'Aprano
2015-05-29 06:16:38 UTC
Permalink
Post by Yongnuan Liu
Hi Everyone,
I am new to Python. I just downloaded Python 2.7.10. I am very frustrated
on starting programming. Here are some questions which I hope you can help
me with?
1. Could someone recommend me a more user friendly python debugging tool?
The simplest debugging tool possible is print.

x = 23
print x # What's the value of x?
Post by Yongnuan Liu
2. Where to download the computing/plotting library, like scipy etc? For
example, when I input a=sin(30), the error says sin is not defined?? it is
just simple calculation and I cannot do it correctly.
from math import sin
a = sin(30) # 30 radians, are you sure you want that?

import math
b = math.sins(math.radians(30))


What operating system are you using? If you are using Linux, you should
be able to get scipy from your OS's package manager. At the shell
prompt, this should work on Linux based systems:

$ sudo yum install scipy numpy

and this should work on Debian based systems:

$ sudo aptitude install scipy numpy

On Windows, there is no package manager, so you will have to go to the
scipy website and download from there. But you may need a C or Fortran
compiler, which most Windows users don't have, so better is to use a
pre-packaged system, e.g. Anaconda:

http://continuum.io/downloads

If you have used Mathematica or another "notebook" based system, you
might like iPython:

http://ipython.org/install.html
Post by Yongnuan Liu
3. How to set up variable enviroment before using these libraries?
I don't understand this question. Can you explain in more detail?
--
Steve
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Loading...