Квиз по Python: Tricky Python Questions

This hard Python quiz is full of snippets that look simple but behave in surprising ways. It covers equal dict keys, operator precedence, nan, empty iterables, class scope and other traps interviewers love to ask about.

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

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

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

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

Вопрос 1 из 10

What does this print?

d = {True: "a", 1: "b", 1.0: "c"}
print(d)
Показать ответ

C. {True: 'c'} True == 1 == 1.0 and they have the same hash, so all three are the same key. The first key object (True) is kept, while each later assignment replaces the value, ending with 'c'.

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

  • Dict keys that are equal, like True, 1 and 1.0
  • Operator precedence with ** and unary minus
  • When a generator expression reads its names
  • nan, all([]) and other edge cases
  • Changing a dict while looping over it, and class body scope

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

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

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

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

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

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

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