🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.1200
  2. B.700
  3. C.900.0
  4. 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 →