2nd Semester Intro to Computer Science

What you will learn

Reading

Do Now

  1. Begin reading the following lessons of the EarSketch documentation in Unit 2.

  2. Answer the following questions, based on the reading:

    • Why might it be useful to group sections of music into functions?
    • Write the code for defining a verse() function that takes in 5 parameters: drums, guitar, bass, startMeasure, and endMeasure.

Lab

Create a new EarSketch project that meets the requirements below. Include your name and project description at the top of the file.

The above is taken from the earsketch teaching resources.

Check your understanding

Pick an answer for each question. You can try again until you get it right.

1. What does A-B-A form mean?

  • A song with three tracks
  • A song that plays the same sound three times
  • A song with a section, a contrasting section, then the first section again
  • A song that is exactly three measures long

A-B-A form returns to the opening section after a contrasting one.

2. Why group the code for a section of music into a function?

  • You can reuse it with different parameters by calling it by name
  • It makes the section play faster
  • It removes the need for variables
  • Python requires every section to be a function

A function is an abstraction: it hides the details behind a name so you can call it again whenever the section returns.

3. What is the purpose of parameters such as startMeasure and endMeasure in a section function?

  • They set the tempo of the whole song
  • They name the function
  • They define which sounds exist
  • They let each call place the section at different measures

Parameters let the same function produce its section at different places in the song.

Downloads