Advertisement
Adehumble

Week8|9 Coding Exercise 3

Apr 1st, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #3
  2. #zombie.py
  3. #This program is written to demonstrates a simple class and how to instantiates a class objects with default values using postional and keyword arguments.
  4.  
  5.  
  6. class Zombie():
  7.     def __init__(self,health=100, brains_eaten=5):
  8.         self.health=health
  9.         self.brains_eaten=brains_eaten
  10.  
  11. bob=Zombie(80,brains_eaten=5)
  12. sally=Zombie(120,3)
  13. benjamin=Zombie()
  14.  
  15.  
  16. #The following prints statements, if uncommented, validates that the corresponding print statements arguments returns the the state of each class objects.
  17.  
  18. #print(bob.health)
  19. #print("\n",sally.brains_eaten)
  20. #print("\n",benjamin.health)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement