Last Updated: January 3, 2026
31 quizzes
Complete the code so the OnlineCourse class correctly inherits from TrainingProgram
class OnlineCourse(TrainingProgramClick an option to fill the blank:
Complete the code so that the Manager class initializes its Employee parent correctly using inheritance
super().(name, salary)Click an option to fill the blank:
Complete the code so that the call uses super() to reach the next implementation of the process method in the MRO
result = super().()Click an option to fill the blank:
Which option best describes inheritance in Python?
In single inheritance, a child class can inherit from how many direct parent classes?
Which class header correctly shows multiple inheritance?
In multilevel inheritance, what best describes the class relationships?
What does Method Resolution Order (MRO) determine?
In a multiple inheritance scenario, which function respects the MRO when calling parent methods?
What is method overriding?
Given class Manager(Employee): pass, what does Manager inherit?
How do you inspect the MRO of a class MyView?
Which statement about super() in single inheritance is correct?
When a subclass overrides a method, how can it still include the parent method’s behavior?
Order the steps to create a multilevel inheritance chain for a billing system where OnlineInvoice is the most specific class.
Drag and drop to reorder, or use the arrows.
Order the steps to safely extend a log method in a multiple inheritance mixin using super().
Drag and drop to reorder, or use the arrows.
What is the output of this code using single inheritance and method overriding?
1class Notification:
2 def send(self):
3 return "Sending generic notification"
4
5class EmailNotification(Notification):
6 def send(self):
7 return "Sending email notification"
8
9note = EmailNotification()
10print(note.send())What is the output when using super() in a simple inheritance chain?
1class Task:
2 def run(self):
3 return "base"
4
5class TimedTask(Task):
6 def run(self):
7 return super().run() + " + timed"
8
9job = TimedTask()
10print(job.run())What is the output when multiple inheritance uses methods from both parents?
1class JsonSerializable:
2 def format(self):
3 return "json"
4
5class XmlSerializable:
6 def format(self):
7 return "xml"
8
9class Hybrid(JsonSerializable, XmlSerializable):
10 pass
11
12obj = Hybrid()
13print(obj.format())What will this code print with multilevel inheritance?
1class Transport:
2 def info(self):
3 return "transport"
4
5class LandTransport(Transport):
6 def info(self):
7 return super().info() + " on land"
8
9class Car(LandTransport):
10 pass
11
12vehicle = Car()
13print(vehicle.info())What is the output when the MRO is affected by class order?
1class A:
2 def who(self):
3 return "A"
4
5class B:
6 def who(self):
7 return "B"
8
9class C(A, B):
10 pass
11
12obj = C()
13print(obj.who())Find the bug in this code that tries to use multiple inheritance for a user report.
Click on the line(s) that contain the bug.
class User: def get_name(self): return "Guest" class Report: def get_name(self): return "Generic Report" class UserReport(User, Report): def summary(self): title = super(Report, self).get_name() return f"Summary for {title}"Find the bug in this multilevel inheritance code that prepares receipts.
Click on the line(s) that contain the bug.
class Document: def __init__(self, title): self.title = title class Receipt(Document): def __init__(self, title, total): self.total = total class OnlineReceipt(Receipt): def __init__(self, title, total, email): super().__init__(total, title) self.email = emailMatch each inheritance-related term with its correct description.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each inheritance pattern with an example scenario.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code so that PremiumUser correctly inherits and extends User with a custom greeting.
class User: def greet(self): return "Welcome user"class PremiumUser(User): def greet(self): base = return base + member = PremiumUser()print(member.greet())Click an option to fill blank 1:
Complete the code to use multiple inheritance for a class that logs both to console and as debug.
class ConsoleLogger: def log(self, message): print("LOG:", message)class DebugMixin: def log(self, message): super().log("DEBUG: " + message)class DebugConsoleLogger(, ): passlogger = DebugConsoleLogger()logger.log("started")Click an option to fill blank 1:
Complete the code so that OnlineOrder correctly reuses Order's initializer in a multilevel chain.
class Order: def __init__(self, amount): self.amount = amountclass SpecialOrder(Order): def __init__(self, amount, label): super().__init__(amount) self.label = labelclass OnlineOrder(SpecialOrder): def __init__(self, amount, label, email): self.email = emailorder = OnlineOrder(50, "gift", "a@example.com")print(order.amount, order.label, )Click an option to fill blank 1:
Complete the code so that AdminUser overrides describe but still includes BaseUser behavior.
class BaseUser: def describe(self): return "Base user"class AdminUser(BaseUser): def describe(self): info = return info + " with admin rights: " + admin = AdminUser()print(admin.describe())Click an option to fill blank 1:
Click the line that determines which save implementation is called according to the MRO.
Click on the line to select.
class BaseSaver: def save(self): print("Base save") class JsonSaver(BaseSaver): def save(self): print("JSON save") class LoggedSaver(BaseSaver): def save(self): print("Logging before save") super().save() class AppSaver(LoggedSaver, JsonSaver): pass saver = AppSaver()saver.save()Click the line where method overriding occurs in this multilevel inheritance example.
Click on the line to select.
class Animal: def sound(self): print("Some sound") class Dog(Animal): def sound(self): print("Bark") class GuideDog(Dog): pass pet = GuideDog()pet.sound()