Key Ideas

  • NumPy is a Python library written in C to provide fast numerical methods for scientific computation.
  • NumPy enables Python users to use a data structure called an array. Think of an array as a list with super powers; they are much more efficient than lists. Arrays look just like a list without commas: [3 5 7 11]
  • Today we will learn about 1-D (one dimensional) arrays. However, Python arrays can contain any number of dimensions.

In-Class Activity

  • One way to gain insight into numeric data is to calculate its mean and standard deviation. More information here.
  • Sometimes it is useful to sort numeric data into either ascending or descending order. Why?
  • Download demo.py and conduct experiments until you fully understand it.
  • Can you explain how the sort function works?
  • The sort function does not return anything. Why does the shoulder_heights array in the main program change?
  • Can you modify the sort function so that it sorts the data into descending order?
  • The NumPy module includes a sort function. Can you find the relevant documentation and then use it?
  • What are other useful things you might want to do with a 1-D array?

Active Learning

Homework