Interview question
What are function annotations? Function annotations क्या हैं?
Answer
def add(a: int, b: int) -> int:
'''Add two integers.'''
return a + b
print(add.__annotations__)
# {'a': int, 'b': int, 'return': int}
from typing import List
def process(items: List[int]) -> int:
return sum(items)def func(a: int, b: str) -> bool:
pass
# Type hints for documentation और IDE supportWas this answer clear?