rangga_hrdme

oop python 1

Apr 9th, 2021 (edited)
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. class Hero: # Main class
  2.     pass
  3. # No OOP
  4. hero1 = Hero() # Attribute/ instance/ instation
  5. hero2 = Hero()
  6. hero3 = Hero()
  7.  
  8. hero1.name = "sniper"
  9. hero1.health = 100
  10.  
  11. hero2.name = "sven"
  12. hero2.health = 200
  13.  
  14. hero3.name = "ucup"
  15. hero3.health = 1000
  16.  
  17. print(hero1)
  18. print(hero1.__dict__) # Show as dictionary
  19. print(hero1.name)
  20.  
  21. # Link: https://www.youtube.com/watch?v=1PjHsUnOkes&list=PLZS-MHyEIRo7ab0-EveSvf4CLdyOECMm0&index=1
Add Comment
Please, Sign In to add comment