← Quiz: SOLID Principles: all 10 questions
Quiz: SOLID Principles · Question 3 of 10
What does this print? (code)
What does this print?
class Base:
def apply(self, x):
return x
class Double(Base):
def apply(self, x):
return x * 2
class AddTen(Base):
def apply(self, x):
return x + 10
total = 5
for step in [Double(), AddTen(), Base()]:
total = step.apply(total)
print(total)
- A.30
- B.25
- C.10
- D.20
Answer & explanation
Correct answer: 20
5 doubled is 10, plus 10 is 20, and Base returns it unchanged.
Can you get the rest right without peeking?
Take the timed Quiz: SOLID Principles quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →