This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Creating and Using NumPy Arrays [Sept. 2, 2012, 1:27 p.m.]


We will directly start with NumPy without attempting to follow the normal approach of first learning Python and then moving up to NumPy. The reasons why I am following this approach is based on the following:

  1. Python is extremely easy to learn and use, and you can learn the Python programming language as you go along.
  2. Knowing Python is not a pre-requisite to begin using NumPy if you are ready to learn as you go.
  3. Accomplishing simple tasks early is a great motivator to learn. Spending some time learning Python when NumPy is your actual goal may be dampener to learning.

There are some extremely good resources to learn NumPy (at least, much better than this course) and you may find them useful as wel as insightful. Start with NumPy and SciPy official documentation.

Importing NumPy Module

Before using NumPy in your code, you must first import the NumPy library. This is not necessary f you are using IPython with the --pylab command line argument because IPython would have imported them already. But importing explicitly a second time is not an error.

There are multiple ways a module can be imported. Here are some:

  1. Importing the library into its own namespace. All functions contained in the module must be called by referring to its module name immediately followed by the function name.
    import numpy
    import numpy

    ....
    x - 0,
    y = numpy(sin)
  2.  
  3.