Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

How add type annotation?

  • We already saw the two examples:
  • Add type annotation to variables.
  • Add type annotation to the function signature.
def add(x: int, y: int) -> int:
    return x + y


def multiply(x, y):
    res: int = x * y
    return res


a: int = 23

z: int = add(a, 19)

result = multiply(a, 19)