American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

5 PM – Python OOP – Bill

February 13, 2023 @ 5:00 pm - 6:00 pm

Today We:
  1. Reviewed Classes and Instances
  2. Learned about using instance variables in lists and dictionaries
Your HW:
  1. Create a new file called “Feb_13_ClassesHerosPractice”
  2. Create a Hero Class with the following attributes:
    1. Name
    2. Power
  3. Give it a default attribute called villains defeated
  4. Give the class the following methods:
    1. display – no parameters – returns the following string:
      • “<name> has <power> powers and has defeated <villains defeated> villains”
    2. defeat a villain – 1 parameter: villain
      • Prints out the following statement: “<name> has defeated <villain>!”
      • Increment the villains defeated attribute by 1
  5. Create a list called hall_of_justice
  6. Fill it with the following Heroes: Batman, Superman, Wonder Woman, flash, cyborg
  7. Using the list, have Superman defeat a villain “Zod”
    have Batman defeat a villain “Joker”
  8. Loop through the list and display each Hero’s information
  9. Loop through the list and have each Hero defeat a villain “Darkseid”
  10. Loop through the list one more time like in step 8 to check all of their villain’s defeated attributes
  11. If you are confused about anything or need help send an email to billhan@ayclogic.com

Details

Date:
February 13, 2023
Time:
5:00 pm - 6:00 pm
Verified by MonsterInsights