add with type checking

    0

    26

    Mainul Islam

    The code defines a function called add. The function takes two int arguments and returns an int. The function is defined using type annotations. The first argument, x, is of type int and the second argument, y, is of type int. The function declaration is prefixed with the keyword def. The keyword def tells the compiler that this code is a definition of a function. The next line in the code specifies the function's return type. The return type is int. The return keyword tells the compiler that this function will return an int value. The function definition follows the return keyword. The first line in the function definition defines the function's name. The second line in the function definition defines the function's arguments. The third line in the function definition defines the function's return value. The fourth line in the function definition assigns the value 5 to the variable x and the value 3 to the variable y. The final line in the function definition ends the definition of the add function.

    ## define add function with type annotations
    def add(x: int, y: int) -> int:
      return x + y
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.