Skills101
← All practice quizzes

Quiz: Design Patterns

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

Design patterns are named, reusable solutions to design problems that keep coming back. The three Gang of Four groups and seven patterns that interviews often ask about, each with a short Python example and the problem it solves.

Log in to take the quiz

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

  1. Question 1

    Which group does the Observer pattern belong to?

  2. Question 2

    What does this print?

    class Logger:
        _one = None
        def __new__(cls):
            if cls._one is None:
                cls._one = super().__new__(cls)
                cls._one.lines = []
            return cls._one
    
    Logger().lines.append('start')
    Logger().lines.append('stop')
    print(len(Logger().lines))
    
  3. Question 3

    A payment module must create a UPI, card or wallet object based on the user's choice, without if/else scattered everywhere. Which pattern fits?

  4. Question 4

    Your code expects send(phone, text) but a vendor library offers push_message(payload). Which pattern connects them?

  5. Question 5

    What does this print?

    class Base:
        def cost(self):
            return 100
    
    class Add:
        def __init__(self, inner, extra):
            self.inner, self.extra = inner, extra
        def cost(self):
            return self.inner.cost() + self.extra
    
    print(Add(Add(Base(), 20), 30).cost())
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →