lab10 : Review for Final (optional)

num ready? description assigned due
lab10 true Review for Final (optional) Tue 06/05 12:30PM Fri 06/08 05:00PM

This lab is a review of concepts from the course so far, and preparation for the final exam.

This lab may be done solo, or in pairs.

Before you begin working on the lab, please decide if you will work solo or with a partner.

Once you and your partner are in agreement, choose an initial driver and navigator, and have the driver log into their account.


In this lab, you will need to create two files:

Starter code is provided for you and is located at the files below (you may need to refresh the page if the links do not load immediately):

For most of the functions the started code and the tests will be enough for you to know what code you are supposed to write.

For the function midi2freq, some additional explanation, provided below, will be needed.

You will complete the portions in the starter code by doing the following:

  1. Create a directory called ~/cs20/lab10 (using the mkdir command) and cd into that directory.
  2. Use idle3 (you might try idle3 & if you want to be able to type commands on your terminal window after IDLE opens).
  3. Use “New File” to create empty files called and in that ~/cs8/lab10 directory.
  4. ONE AT A TIME, copy the function definitions from the starter code, write tests that go along with those functions in, and get your tests to pass.
    • Before you move on to the next function definition and its tests, get all of the tests you just wrote to pass.
    • Repeat this until you have ALL of the function definitions and their tests, and all of them pass.

You are encouraged to try submitting to Gradescope periodically for several reasons:

Explanation of midi2freq

For electronic musical instruments (for example, keyboards), each key on the keyboard is assigned a particular “midi number”, an integer corresponding to the numbers on the illustration shown here:

midi chart

(adapted from an article by Joe Wolfe, University of New South Wales)

Each note on an instrument has a certain frequency, with notes to the right having higher frequencies, and notes to the left having lower frequencies. When instruments are tuned in the usual way*, the formula to convert from a midi number m to a frequency f is expressed as follows in math notation:

Your job when writing the definition for midi2freq is to write a Python function that computes this value. This formula is value when $m$ is an integer between 0 and 127 (inclusive).

* For the music geeks, A=440Hz, equal temperament.

Upload and to Gradescope.

Once you’re done with writing your functions, navigate to the Lab assignment lab10 on Gradescope and upload your and files.

Remember to add your name, and your partner to Groups Members for this submission on Gradescope if applicable. At this point, if you worked in a pair, it is a good idea for both partners to log into Gradescope and see if you can see the uploaded files for lab10.