Python Programming for the Absolute Beginner, 3rd Edition

  1. Improve the Critter Caretaker program by allowing the user to specify how much food he or she feeds the critter and how long he or she plays with the critter. Have these values affect how quickly the critter's hunger and boredom levels drop.

  2. Write a program that simulates a television by creating it as an object. The user should be able to enter a channel number and raise or lower the volume. Make sure that the channel number and volume level stay within valid ranges.

  3. Create a "back door" in the Critter Caretaker program that shows the exact values of the object's attributes. Accomplish this by printing the object when a secret selection, not listed in the menu, is entered as the user's choice. (Hint: add the special method __str__() to the Critter class.)

  4. Create a Critter Farm program by instantiating several Critter objects and keeping track of them through a list. Mimic the Critter Caretaker program, but instead of requiring the user to care for a single critter, require them to care for an entire farm. Each menu choice should allow the user to perform some action for all of the critters (feed all of the critters, play with all of the critters, or listen to all of the critters). To make the program interesting, give each critter random starting hunger and boredom levels.

Категории