Advertisement
albin900

Calsses

Jul 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1.  
  2. class Person:
  3.     def __init__(self, name, age, sex):
  4.         self.name = name
  5.         self.age = age
  6.         self.sex = sex
  7.        
  8.     def calculateBornYear(self):
  9.         return 2017-self.age
  10.        
  11.        
  12.  
  13. michael = Person( "Michael", 18, "Male")
  14.  
  15. albin = Person( "Albin", 15, "Male")
  16.  
  17. hillary = Person( "Hillary", 69, "Female")
  18.  
  19.  
  20. print michael.age
  21.  
  22. print albin.calculateBornYear()
  23.  
  24. print hillary.sex
  25.  
  26. print michael.sex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement