June 2017
Beginner to intermediate
274 pages
6h 49m
English
The following code example shows off Python's function annotation syntax:
To associate a value with a parameter, we put a colon (:) after the parameter name and then write an expression. This expression will be evaluated when the function is defined and the result stored along with a parameter name.
We can also annotate the return value of a function by writing a -> arrow symbol after the function's parameter list and then an expression, which will also be evaluated when the function is defined. The result is stored along with the word return. Because return is a keyword, there is no chance that it will collide ...
Read now
Unlock full access