Computer Sciences 303e - Programming Assignment 3
 (due by 11 pm, Friday, February 25)


Covered Topics: Input from the keyboard, while loops, nice looking output, functions


Your program will prompt the user to enter a series of animal names and sounds, and print the corresponding verses from the song "Old MacDonald had a farm". Your program will continue printing verses until the user enters "no" instead of an animal name.

Your program should use functions to reduce redundancy in the program.

Sample output (with the user's inputs in green):

Let's sing "Old MacDonald had a farm":
Please enter an animal, or no to stop playing: duck
Please enter a noise: quack

Old MacDonald had a farm, E-I-E-I-O
And on that farm, he had some ducks, E-I-E-I-O
With a quack-quack here, a quack-quack there
Here a quack, there a quack
Everywhere a quack-quack
Old MacDonald had a farm, E-I-E-I-0

Please enter an animal, or no to stop playing: cow
Please enter a noise: moo

Old MacDonald had a farm, E-I-E-I-O
And on that farm, he had some cows, E-I-E-I-O
With a moo-moo here, a moo-moo there
Here a moo, there a moo
Everywhere a moo-moo
Old MacDonald had a farm, E-I-E-I-0

Please enter an animal, or no to stop playing: no

--------------------------
Some additional rules:

0. Your program must contain a main function, which in turn calls other functions. The only statement in your program that is not contained in a function should be a call to the main function.

1. Your program should include a function that contains a print statement that prints the first and last line of each verse. Call this method twice instead of using 2 different print statements in your main function.

The header for this function will look like this:

def printFirstLast():
     # your print statement goes here

2. Your program should also contain a method that takes an animal and noise, and prints the middle 4 lines of each verse. The header for this method will look like this:

def printMiddleVerse(animal, noise):
     # your code here


3. Remember that we can compare two strings with ==.


Name your class MacDonaldSong and submit your source file MacDonaldSong.py by 11 pm on the due date. Make sure you include a comment header in your class that contains all required information (your name, EID, etc - see the project 1 specification for a more complete description), as well as a description of slip days if you are using them on this project:


 # slip days used on this assignment: ?
 # total slip days used: ?
 #
 

Use the coding conventions we have discussed and used in class (eg, conventions for variable names) and include whitespace (e.g., blank lines) and comments to make your program more readable.

Programs that contain syntax errors will receive no credit. Please start early so that you will have time to ask for help if you need it.

Half your score will be based on the correctness of your output: it must exactly match the sample output given above.

The other half of your score will come from the internal correctness of your program: using Python constructs correctly (e.g., while loops), following the rules stated above, including the comment header as indicated, using whitespace and comments for readability, using the conventions we've discussed for variable names.

Submit your program MacDonaldSong.py via turnin by 11 pm on the due date. 

If you use slip days to submit your project late, you must email the proctors (and them only) when you submit your program, so that they know it's ready to be graded.

Did you remember to: