Appendix A: VS Code

To get starting programming we are going to need to set up our development environment. You will do that in the next appendix on uv. Development environments are the locations where you do the actual programming (or develop the program, hence the name). They include the text editor and all the tooling that makes programming a more enjoyable experience. To get started we will need to download an integrated development environment (IDE), and Jupyter, which is the standard way to write Python for data analytics (more on this below).

Integrated Development Environments (IDE)

We write code in plain text. Originally, we used text editors to write code, but now we have developed entire environments that support the plain text to make programming a more enjoyable experience with various features such as:

  • Syntax Highlighting: Colors the text based on its role (e.g., keywords, variables, strings) to improve readability and understanding of the code structure.
  • Code Completion: Offers suggestions for code as you type, including function names, variables, and methods, reducing typing effort and errors.
  • Error Detection: Highlights syntax errors or potential issues in real-time, helping you debug code faster.
  • File Tree Navigation: Allows you to easily navigate through files and directories in your project, making it simpler to manage large codebases.

VS Code

I recommend you use VS Code for throughout the class. VS Code is an open source and open access IDE developed by Microsoft. It supports almost all programming languages that are actively used today. Because it is open source, Microsoft has made it easy for users to produce their own add-ons to extend the functionality of VS Code. These are called plugins. Programmers build plugins to make the development experience more user-friendly. Due to the plugins and active development, VS Code is the most used IDE on the market.

Downloading VS Code

You can download VS Code from the official website: VS Code Downloads. Follow the installation instructions for your operating system (Windows, macOS, or Linux).

During installation, you will be prompted for three options:

Needed Plugins

In order to benefit from the full use of VS Code, you will need to install a number of plugins that enhance the Python support of VS Code.

  • Jupyter: (From Microsoft) This plugin allows you to work with Jupyter Notebooks directly within VS Code, providing a rich interface for interactive computing. (For more on Jupyter Notebooks, see below).
  • Jupyter Notebook Renderers: (From Microsoft) This plugin enhances the rendering of Jupyter Notebooks in VS Code, providing a better visual experience for your notebooks.
  • Pylance: (From Microsoft) This plugin provides fast and feature-rich language support for Python, including type checking, code completion, and more.
  • Python Environments: (From Microsoft) This plugin helps you manage and switch between different Python environments easily.

The Basics of Jupyter Notebooks

Python runs in .py files. These files run from the top down, and run until either they get to the end or encounter an error. This functionality can be frustrating when working with complicated data sets that demand significant computational power to query. When you make a mistake or explore, you would have to re-query the data over and over again. Jupyter Notebooks solve this problem by sandboxing the Python environment and breaking the file into individual cells that can run independently. In other words, you can query the data, save it in memory, and then continue working with it in subsequent cells without having to re-run the entire script.

Rather than running in a .py file, Jupyter Notebooks run in .ipynb files. Under the hood, ipynb files are JSON files. Never run them in an environment that does not support Jupyter Notebooks, because you will modify the JSON rather than the underlying cells. VS Code creates an entire environment for Jupyter Notebooks when you open an .ipynb file. You can run the cells by clicking the “Run” button next to each cell, or by using the keyboard shortcut Shift + Enter.