In this chapter, you learned how to work with NumPy arrays. NumPy is a Python package used for numerical calculations and arrays. An array is a data structure only contains objects that share the same data type. Arrays are faster than lists in large-scale numerical calculations.
You learned how to create arrays in a variety of ways:
- Create an array from a Python list with
- Create an array of regularly spaced numbers with
- Create an array of random numbers with
- Create two 2D arrays from two 1D arrays with
You learned how to index and slice arrays. Slicing NumPy arrays share the same syntax used to slice Python lists and strings.
At the end of the chapter, you learned how to run mathematical operations on arrays. NumPy's mathematical functions operate on arrays like Python's math functions operate on integers and floats. NumPy has additional functions like
np.cross() that cannot be applied to scalars. NumPy's
np.linalg.solve() function can be used to solve systems of linear equations.
Key Terms and Concepts
homogenous data type
system of linear equations
logarithmically spaced numbers
matrix multiplication methods