E21 Computer Engineering Fundamentals
September 29, 2026
numpy with Thonny Code Editor

numpy arraysnumpy are similar to lists.
for loopsAfter installing numpy for your version of Python, you need to import numpy in any code you write.
A common approach is:
This shortens numpy.<function name> to np.<function name> and has no other function.
Other approaches that work:
Import using full name
Import specific functions only
numpy arrays are inherently n-dimensional[row,column] syntaxp[1,2] will give the string"g"numpy arrays support vectorized operationsnumpy Approach>>> f = np.array([[0.3, 0.5, 0.6],
[0.2,-0.3, 0.7]])
>>> f + 100
array([[100.3, 100.5, 100.6],
[100.2, 99.7, 100.7]])
>>> f ** 2
array([[0.09, 0.25, 0.36],
[0.04, 0.09, 0.49]])
>>> f = np.array([[0.3, 0.5, 0.6],
[0.2,-0.3, 0.7]])
>>> g = np.array([[0.2, 0.5, -0.6],[0.2,-0.3,1.9]])
>>> f == g
array([[False, True, False],
[ True, True, False]])
Numpy arrays have a property shape
numpy and floating-point binary numbersBy default, all numbers in numpy are 64-bit floating point binary numbers.
You can choose numbers with a different precision.
numpyDownload the data file here and look at the official documentation here
Consists of 3 days of temperature data recorded at half-hour intervals.
numpy array.csv files for the three days separately.array()zeros()reshapeappendflattentransposesavetxtloadtxtnumpyTry out the following code and explain the behavior. Make sure you use immport numpy as np first.
E21 • Fall 2026 • Lecture 09 • September 29, 2026 • ↩︎