Omniadisce

Computational physics 4.1: NumPy, a library, and arrays

Lesson Beginner

Join free to take this lesson

Anyone can look around, but taking a lesson needs a free account. With one, your answers are checked step by step and your progress is saved, so you can stop and pick up where you left off on any device.

13 steps ยท about 20 min

By the end you can

  • Say what a library is, and load NumPy with import numpy as np
  • Read an error that says np is not defined, and fix it
  • Make an array from a list with np.array
  • Count an array's elements with len, and read one with [0], [1] or [-1]

Who it is for: Anyone who has done units 1-3 of this course (print, variables, loops, functions and lists).

The steps

  1. A list and a loop (a recap)
  2. A library: tools someone else wrote
  3. Your first import
  4. Forgetting the import
  5. Add the import
  6. An array: a list NumPy can do sums with
  7. Make an array
  8. Making an array
  9. Fix the bug
  10. Like a list: len and indexing
  11. The first time
  12. The last one
  13. In your own words

Discussion 0 comments

Log in to join the discussion.

× Enlarged view