Python is a general-purpose programming language widely used in a variety of fields, including computational humanities research (and computational musicology in particular). Once you have Python installed, type the following and hit enter to print your first message: The print function displays the elements in parentheses in the console window. This can be a string […]
Tag: tutorial
For Loop (Python)
A for loop is used to iterate over a list or other sequence. The for loop is a fundamental building block of Python programming. Let’s say we we have values stored in a list (notes, intervals, rhythms, etc.) and we want to step through or iterate through them in order to display them or perform […]
List Comprehension (Python)
A list comprehension is a concise way to build a list. It is often used in place of a for loop when creating a new list based on an existing list. For example, let’s say we have a list of pitches (MIDI note numbers) and we would like to generate a list of pitch classes: […]
Python Installation
Get started with Python by following the installation instructions. Here are a few options we recommend for running Python: Terminal (Mac) You can run Python directly in the Terminal on a Mac (Applications -> Utilities -> Terminal). This allow you to get going right away without installing any additional software. Using an IDE You can […]
Music21 Installation
This quick tutorial post explains how to install music21, a library of musicological tools for Python. For general instructions on how to install a Python library, see this page. How to install music21 on a Mac. How to install music21 on a PC (Windows). Once you install music21, you can load it in Python with […]