culTest

    One of the 50 questions in this topic

    How much do you know about Python?

    What are type annotations in Python?

    Answers

    Special comments documenting types
    Optional indications of types that do not affect executionCorrect
    Restrictions that force specific types
    Metadata to optimize performance

    Type annotations (introduced in Python 3.5+) are optional prompts that suggest expected types for variables, parameters, and return values. For example: def sum(a: int, b: int) -> int:. They don't affect execution or force types (Python is still dynamically typed), but tools like mypy can check them statically. They improve documentation, facilitate autocompletion in IDEs, and help detect errors before execution.