2.1 DOWNLOADING PYTHON
To run Python code, you need to use a Python compiler. In this text, we will be using the Spyder compiler, which is included in the Anaconda software package. By downloading and installing Anaconda, we will also download and install Python at the same time.
To download Anaconda, go to the Spyder installation page1 and select the Anaconda link under either the Windows or MacOS X options. After the installation is complete, locate the Spyder program and open it.
When you open Spyder for the first time, you will see the screen shown in Figure 2.1. The left‐hand box is where you will write Python code. That box is where we will spend most of our time. The top‐right box lists data sets and other items that have been created by running Python code. The bottom‐right box is where our output will appear, as well as any error messages or other information.
2.2 BASICS OF CODING IN PYTHON
In Python, as in most other programming languages, you run code which performs an action. Some actions also generate output. There are five kinds of actions we will focus on in this chapter: Using comments, Importing packages, Executing commands, Saving output, and Getting data into Python.
2.2.1 Using Comments in Python
Comments are pieces of code that are not executed by the ...