CS106L Introduction to Computing and Programming in Python (Lab)
Fall 2008

Lab 9

Code for Lab 9

lab9.py

Class Assignment

Create a getClip function for the "gettysburg10.wav" file from the MediaFiles directory. This function should return only the first 6 words of the Gettysburg address.

You should assume that the media path has already been set with setMediaPath(), so you should be able to call getMediaPath directly when loading the original WAV file.

Home Assignment

  1. Using the getClip function from your class assignment, separate the 6 words form the beginning of the Gettysburg address. Create a function for each word (so, 6 functions) that can be called to get only that word.

    For each of the 6 functions:
  2. Write a function that takes a single integer as input. This integer corresponds to the number of the word in the first 6 words of your Gettysburg clip.

    So, "Four score and seven years ago" has integers of 0:"four" 1:"score" 2:"and" 3:"seven" 4:"years" 5:"ago"

    This function should use your functions from part 1 to return the individual word corresponding to the integer given as input.




Last modified: 10-23-2008
By: David O'Gwynn