题目
MCD4710 Introduction to Programming - Trimester 2 - 2025
多重下拉选择题
Fill in the blank with the correct option to complete the below given code:from abc Blank 1 Question 7[select: , from abstract import, using ABC, import ABC] , abstractmethodclass Employee(Blank 2 Question 7[select: , ABC, Base, Object] ): def __init__(self, name): self._name = name @abstractmethod def calculate_salary(self): Blank 3 Question 7[select: , pass, return 0, print("Not implemented")] class Developer(Employee): def __init__(self, name, hourly_rate, hours_worked): super().__init__(name) self._hourly_rate = hourly_rate self._hours_worked = hours_worked def calculate_salary(self): return self._hourly_rate * self._hours_worked
查看解析
标准答案
Please login to view
思路分析
The task asks us to fill in three blanks in the given Python code that uses abstract base classes (ABC).
Blank 1: The line begins with from abc ___. The correct import statement to access ABC and @abstractmethod is: from abc import ABC, abstractmethod. However, since only one of the provided dropdown options is requested for Blank 1, the choice 'from abc import' is appropriate because it provides the module name needed before......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
What happens if you try to instantiate an abstract class?
Does Java allow an abstract class to be a child of a parent class that is also abstract?
from abc import ABC, abstractmethod class DataProcessor(ABC): def __init__(self, data): self.data = data @abstractmethod def clean(self): pass def process(self): cleaned_data = self.clean() return sum(cleaned_data) class ListProcessor(DataProcessor): def clean(self): cleaned = [] for x in self.data: if isinstance(x, (int, float)): cleaned.append(x) return cleaned class AveragingProcessor(ListProcessor): def process(self): cleaned = self.clean() return sum(cleaned) / len(cleaned) dp = ListProcessor([1, 2, "a", 3]) ap = AveragingProcessor([10, None, 20, 30, "skip"]) print(dp.process()) print(ap.process()) What will happen when the above code is executed? Select all correct statements. Incorrect selections will deduct points from your score.
Can an abstract class be a child class of another abstract class?
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!