|CS 220 01/ Zelle||Winter 2019|
Chapter 1 Review Questions (pt 1) (due 1/11, class time)
Do T/F questions 1--5 and Multiple Choice 1--3 from pp 33,34. Write answers on paper suitable for hand-in at the start of class.
Elapsed Days functions (due 1/14)
You should implement and test the functions that we have been working on in class. So far, we have the following:
Elapsed Days program (due 1/21, midnight)
Implement and test the complete elapsed days program that we have been designing in class. The input to the program is two dates entered by the user. The output is the total elapsed days between the two dates. Here are the rest of the function specifications from the class design:
You have considerable latitude in how to implement each function in this design, including your main program, but you must implement the 6 functions as specified. If you have any questions about the design, ask for clarification.
You should strive to adhere to the guidelines for good program design that you learned in CS 120. Use descriptive variable names, good explanations/prompts for your users, and readable code layout. Use functions to avoid code duplication, and be sure to include descriptions of the functions as docstrings (see specifications above for help with that). You do not need to express these descriptions as pre- and post- conditions (ala Section 1.2 of our tetbook), but you certainly may do that if you want to.
stats2.py (due 1/23, midnight)
Programming Exercise #7 on page 38.
Chapter 1 Review Exercise (pt. 2) (due 1/25, class time)
Do T/F Exercises 5--10 and Multiple Choice 4--10 from Chapter 1.
Sort Timing Report (due 1/30, class time)
In this assignment you are to complete an implementation of the selection sort algorithm that we discussed in class and experimentally compare this algorithm to the built-in Python list method for sorting. You should begin by downloading the starter code from our handouts folder: sort_timer.py You need to write implementations for the first three functions in the file.
Use your functions to experimentally test the efficiency of your selection sort and Python's sort. Then write a short report consisting of: the code that you wrote (cut and paste it into your report) and a brief discussion of your results, answering the following issues:
Read Chapter 2
Reminder: Exam 1 on 2/8
Due to our unexpected day off, the exam was moved back a class day. Please plan accordingly.
Chapter 2 Review Questions (due 2/6, class time)
Do the True/False and Multiple Choice questions from the end of Chapter 2. Have your answers on paper ready for hand-in at the start of class.
dataset_sum.py (due 2/13, midnight)
In class, we implemented a new Dataset object that encapsulated the list data structure that we originally used in our simple statistics library. Now that we have an ADT for Dataset, we can experiment with different implementations. Your assignment is to write an implementation of the Dataset class that does not store the numbers in a list. Your new class should be placed in a file called dataset_sum.py.
In our handouts directory, you can find a folder (dataset) of starter code. The dataset.py file is is the specification for the Dataset class. run_stats.py is a simple interactive program that uses a Dataset to calculate statistics for a set of numbers entered by the user. The last file test_dataset.py uses the Python unittest module to test the Dataset class. The testing programs currently import from dataset_list. That should allow them to run with the code that we develop in class. You can test your dataset_sum code by changing the imports at the top of the testing file to use dataset_sum instead of dataset_list.
cribbage.py (due 2/22, midnight)
Create Card, Deck, and Hand classes that would be a suitable starting point for writing a Cribbage playing program. Starter code is available in the handouts folder. Your classes must implement all the methods that are specificed in the starter code, and you should have unit tests for the Hand class to ensure that it counts points properly. Your classes may include additional "helper" methods. These helpers should have names that start with _.
You should also turn in a demo program (cribbage.py) that deals a hand of 4 cards from a shuffled deck, displays it in sorted order and then calculates and displays the "expected value" of the hand. The expected value is the mean (average) score of the hand when scored with each of the remaining 48 potential starter cards.
Chapter 3 Review Questions (due 2/25, class time)
Finish reading Chapter 3 and do the True/False and Multiple Choice questions at the end of the chapter.
Morse Encoder/Decoder (due 3/1)
You are to write a program that encodes/decodes sentences to/from Morse Code. We will use "." and "-" to represent the dots and dashes. Letters in Morse code will be separated by a space, and words will be separated by two spaces. In our handouts folder, you can find a file called "morsechars.txt" that has the encodings of characters as sequences of dots and dashes.
Your program should contain a MorseCoder class with the following methods:
class MorseCoder: def __init__(self, charfile): """Create a MorseCoder with character encodings from charfile """ def encode(self, s): """Return encoding of string s into Morse code""" def decode(self, s): """Return decoding of Morse string s"""
cdcollection.py (due 3/13, midnight)
def main(): print('testing...') c1 = MusicCD('Pink Floyd', 'The Final Cut') assert c1.artist == 'Pink Floyd' assert c1.album == 'The Final Cut' c1.addtrack('The Post War Dream', 182) c1.addtrack('Your Possible Pasts', 262) assert c1.tracks == [('The Post War Dream', 182), ('Your Possible Pasts', 262)] c2 = MusicCD('Sleepy Bones Allison', 'Blues Alive') c2.addtrack("Moon Thing", 267) c2.addtrack("Fair Warning", 307) c2.addtrack("February 31st", 255) assert c2.duration() == 829 c3 = MusicCD('Stevie Ray Vaughan', "Couldn't Stand the Weather") c3.addtrack('Pride and joy', 301) c3.addtrack('Texas Flood', 487) collection = CDCollection() collection.addCD(c1) collection.addCD(c2) collection.addCD(c3) collection.printCDs() print('passed') if __name__ == '__main__': main()And here's the output:
testing... Album: Couldn't Stand the Weather Artist: Stevie Ray Vaughan Duration: 788 Album: Blues Alive Artist: Sleepy Bones Allison Duration: 829 Album: The Final Cut Artist: Pink Floyd Duration: 444 passed
Start reading Chapter 5
Yes, we are skipping Chapter 4, except for highlights that I will cover in class.
Marble Clock (due 3/25, midnight)