Skills101
← All practice quizzes

Quiz: SOLID Principles

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

The five SOLID principles of object-oriented design, each with a small "before and after" Python example, plus DRY, KISS and YAGNI. What each rule protects you from, and when not to over-apply it.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    A class calculates salary, formats the payslip PDF and saves it to the database. Which principle does it break?

  2. Question 2

    What does "open for extension, closed for modification" mean?

  3. Question 3

    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)
    
  4. Question 4

    Square extends Rectangle and changes set_width so that it also sets the height. Code written for Rectangle now gives wrong areas. Which principle is broken?

  5. Question 5

    A BasicPrinter class implements a Machine interface and raises an error in scan() and fax(). What is the best fix?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →