We use the class definition syntax that we learned from the previous lecture to build a game! First we'll design the class, i.e., our own custom type; then we implement the class in order to create a word guessing game. Along the way, we discuss how to overload special methods.

Do before lecture

Review the slides, examples, and your notes from the previous lecture (Lecture 17) so that you are ready to apply what was discussed. Did you answer the two questions at the end of those lecture slides? Be sure to do them!

AND read 17.6 - 17.12

Lecture materials

Slides: individual slides for viewing, 6-up layout for printing


To download the above .py files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as".
This way you choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).

Lecture Recording

Answers to the questions on slides 29 and 31: First try to complete the implementation of class SecretWord in the file wordGuesss.py (skeleton file given above). Afterwards take a look at our version.

After lecture, watch this 8-minute video on operator overloading.