Those are type signatures. And you can read all about them in PEP 484. They don't do much of anything on their own, but they're extremely useful with a tool like mypy.
def getMinMax(arr: list, n: int) -> pair:
minmax = pair()
This declares that getMinMax
takes two arguments: arr
and n
. The type of arr
is list
and the type of n
is int
. The function will return a value of type pair
. Again, none of this affects Python proper (although you can access the type signatures in Python using reflection, they have no bearing on the runtime by default), but you can use it to run compile-time verification on your code.
If you found this code in the wild and just want to interact with it, you can safely ignore the type annotations. But I strongly recommend you read PEP 484 (it's actually quite digestible, and I recommend reading it in full). It's got a ton of useful stuff, and it's very helpful.