Advertisement
Fahim_7861

inheritance phython

Mar 4th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2.  
  3. class Person:
  4. def __init__(self, fname, lname):
  5. self.firstname = fname
  6. self.lastname = lname
  7.  
  8. def printname(self):
  9. print(self.firstname, self.lastname)
  10.  
  11. class Student(Person):
  12. def __init__(self, fname, lname, year):
  13. super().__init__(fname, lname)
  14. self.graduationyear = year
  15.  
  16. def welcome(self):
  17. print("Welcome", self.firstname, self.lastname, "to the class of", self.graduationyear)
  18.  
  19.  
  20. x=Student("fahim ahmed","Shojib",2020);
  21.  
  22.  
  23. x.welcome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement