Welcome to Chapter 1, where your journey begins! Here, we study the fundamentals of creating Python code. The two key components to any modeling analytics are (1) variables and (2) functions. Variables allow us to “hold on” to information Python, it gives us a place to store data so that we may reference and use it. Functions allow us to define certain operations that we want to be done to the data. While on our learning adventure, we’ll emphasize best practices to ensure that your analysis is well-documented (this will save you or colleagues a lot of time in later deciphering what your code is doing!).

At the end of this chapter, you’ll be able to:

  1. Record numeric/string values to Python variables

  2. Add comments to code to label what specific commands do

  3. Create a basic function that returns a value to the user

  4. Write functions that anticipate and address erroneous user inputs