Квиз по Python: Type Hints

This Python quiz checks how well you understand type hints, from int | None and list[str] to Callable, Literal and NamedTuple. It also tests the most common misunderstanding of all - that Python checks your hints when the code runs.

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

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

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

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

Вопрос 1 из 10

What does this print?

def add(a: int, b: int) -> int:
    return a + b

print(add("4", "2"))
Показать ответ

C. 42 Python does not check type hints when the code runs. The two strings are simply joined with +, giving 42. A static checker like mypy would flag this call before you run it.

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

  • Hints are not enforced at run time
  • int | None, list[str] and dict[str, int]
  • Callable, Literal and NamedTuple
  • __annotations__ and static checkers like mypy
  • Hints and isinstance()

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

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

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

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

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

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

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