intro-to-python icon indicating copy to clipboard operation
intro-to-python copied to clipboard

Static Typing / Function Annotations

Open s2t2 opened this issue 3 years ago • 0 comments

Add this to the notes about functions:

"for example, this function is expected to take two int arguments and is also expected to have an int return value:"

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

References:

  • https://docs.python.org/3/glossary.html#term-type-hint
  • https://docs.python.org/3/glossary.html#term-function-annotation

s2t2 avatar May 26 '21 19:05 s2t2