← Quiz: SOLID Principles: all 10 questions
Quiz: SOLID Principles · Question 7 of 10
What does this print? (code)
What does this print?
class Discount:
def apply(self, price): return price
class Festive(Discount):
def apply(self, price): return price * 0.5
class Flat100(Discount):
def apply(self, price): return price - 100
total = 0
for d in [Discount(), Festive(), Flat100()]:
total += d.apply(400)
print(total)
- A.1200
- B.700
- C.900.0
- D.900
Answer & explanation
Correct answer: 900.0
400 + 200.0 + 300 = 900.0; the float from Festive makes the total a float.
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 →