Квиз по Python: Python OOP Interview Questions

This Python quiz covers the object-oriented questions that come up in most Python interviews. You will trace super() through multiple inheritance, see what name mangling really does, and check your understanding of abstract classes, __slots__ and duck typing.

Средний 10 вопроса ~6 минуты Проходной балл: 80% Python 3.12

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

Пример вопроса

Вопрос 1 из 10

What does this print?

class Basket:
    items = []

    def add(self, item):
        self.items.append(item)

a = Basket()
b = Basket()
a.add("apple")
print(b.items)
Показать ответ

B. ['apple'] items is a class attribute, so there is one list shared by every Basket. self.items.append changes that shared list. Create the list in __init__ with self.items = [] to give each object its own.

Что проверяет этот квиз

  • Shared mutable class attributes
  • super() and the MRO in multiple inheritance
  • Name mangling with __name
  • Abstract base classes and __slots__
  • Duck typing and composition

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

Какая версия Python?

Python 3.12. Каждый вопрос о выводе программы проверен запуском кода.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.