Compsci 6/101, Fall 2011, Lab 2

Song Problems

Turn in this page for your group

Write two separate programs that each print out the lyrics to the following common children's songs:

Do not use more advanced features than what we have covered in class (statements and functions).

To start, use Eclipse to make a new project for this lab. Within this project, you will create two separate Python modules, one for each song listed above. This page describes how to do this for a previous version of PyDev (i.e., some of the menus look slightly different).

Using Functions

It is easy, of course, to write the program using a series of print statements for each line of the song. But the goal of this lab is to take advantage of the cumulative structure of the song to avoid redundancy. Look for ways to use functions to avoid simple redundancy and functions with parameters to avoid the structural redundancy within the songs. In particular, make sure that you use no more than one print statement for each distinct line of the song.

For example, the line in the song The Farmer in the Dell:

Hi-ho, the derry-o.

appears several times, but your program that generates the song should have only one print statement that produces this line which is defined in a function that is called multiple times within your program.

Likewise, the following lines from the song Here We Go 'Round the Mulberry Bush:

So early Monday morning
So early Tuesday morning

are structurally the same, with only the words Monday and Tuesday different. Again, your program that generates the song should have only one print statement that produces these lines which is called multiple times within your program with different parameters.

Your output of the song lyrics should be as similar as possible to what appears on the websites, including line breaks and blank lines. Although if you cannot easily match the capitalization or punctuation, that is okay.