2nd Semester Intro to Computer Science

Lab 7.02 - Pet Class

In this lab, we will create a Pet class that will keep track of the type of animal, color, food, noise and name of a given animal.

Create a class called Pet that has the following attributes

  • Animal (i.e. dog, cat, fish)
  • Color (i.e. spotted, black, tabby, white)
  • Food (i.e. kibbles, tuna, fish flakes)
  • Noise (i.e. meow, woof, bark)
  • Name (i.e. Sparky, Scooby Doo)

Specifications

  1. Make sure to use the __init__ method to create these attributes.
  2. Create a list of pets.
  3. Create a function that takes in a list of pets and prints out the name and the food attributes.
  4. Test your function with your list of pets.

Edit this page Report an issue