Questions
Questions

FIT9136 Introduction to Python programming - S2 2025

Multiple choice

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.

Options
A.a. The class AveragingProcessor inherits both clean() and process() from ListProcessor
B.b. ListProcessor is instantiable after overriding clean() without overriding process()
C.c. The code will raise a TypeError when calling dp.process()
D.d. The method clean() will raise a ValueError if the input list contains None
E.e. The @abstractmethod decorator prevents instantiating DataProcessor directly
Question Image
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
To tackle this question, I’ll walk through what each part of the code does and then evaluate each statement against that behavior. Option a: The class AveragingProcessor inherits both clean() and process() from ListProcessor. In reality, AveragingProcessor defines its own process method, overriding the one it would otherwise inherit. Therefore it does not inherit th......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!