Working on Problem Set #8 / Problem #2 (2008 version of the course) Specifically, I'm trying to create the ShapeSet class. It's not clear to me what variables to initialize in the def __init__: part of the problem. I think that I need some sort of container to hold the different shapes that I'll be putting into the class. But is it a list? a dictionary? I might be off base here
yep .. you need something to hold all the shapes. you could use one of Python's sequence types or mapping types or set types. You could create your own container - wasn't there a lecture and maybe a chapter in how to think like a comp sci about making a linked list - you could use one of those. The important thing is you need to decide what kind of functionality you need in the container - then choose the right one, or create your own data structure. How To Think Like a computer Scientist: chapter 15 is a good read - it is a similar design process chapter 17 is about linked lists Appendix B is what this exercise is about - creating new data types
Thanks! The pointer to the "How to Think like a Computer Scientist" did the trick.
Join our real-time social learning platform and learn together with your friends!