lab10 : Review for Final (optional)

num ready? description assigned due
lab10 true Review for Final (optional) Mon 06/04 08:00AM Fri 06/08 05:00PM

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

It is optional in the sense that if you are satisfied with your grade on the labs so far, you don’t have to complete it. I will be dropping the lowest grade of your lab grades, and if you don’t complete this lab, and get a zero, that zero will be dropped from your grade.

But if you do complete it, it is to your benefit.

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.

A reminder about working with a pair programming partner:

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

Instructions

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 ~/cs8/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 lab10.py and lab10_student_tests.py 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 lab10_tests.py, 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 lab10.py and lab10_tests.py to Gradescope.

Once you’re done with writing your functions, navigate to the Lab assignment lab10 on Gradescope and upload your lab10.py and lab10_tests.py 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.