Quiz Catalog

Catalog of quizzes

class Person:
  def __init__(self, fname, lname):
  self.firstname = fname
  self.lastname = lname

  def printname(self):
  print(self.firstname, self.lastname)

class Student(Person):
  def __init__(self, fname, lname):
  super().__init__(fname, lname)

x = Student("Mike", "Olsen")

x.printname()
Mike Olsen
  • class/super
  • class/inheritance

class Person:
  def __init__(self, fname, lname):
  self.firstname = fname
  self.lastname = lname

  def printname(self):
  print(self.firstname, self.lastname)

class Student(Person):
  def __init__(self, fname, lname):
  self.fname = fname
  self.lname = lname
  
x = Student("Mike", "Olsen")

x.printname()
AttributeError: 'Student' object has no attribute 'firstname'
  • class/super
  • class/inheritance