3. CompSci 101: Types, control, and numpy arrays#

This is where we start with some computer science basics. Essentially, where every coding class begins. We’ll discuss data types and data structures, such as the differences between integers and floats, booleans (i.e. True or False), a bit about strings (text), and lists.

We’ll then get into more Python-specific material and introduce the crucial numpy package. This package will allow us to use arrays in Python. Arrays are a way to store things, like numbers, in Python.

Numpy arrays allow us to do a lot of different math, like linear algebra, in Python and are much faster than the Python list data type.

I also mention functional programming (something we’ll come back to) and control structures, like if and else statements.

These notes follow along with Chapters 3 and 4 of Python for Finance, 2e.

Finally, you’ll find a lot of this material in the Coding Basics section of Coding for Economists