What is the output of the following Python code snippet?
def f(x: int) -> int:
return x
print(f.__annotations__)
-
A
None
-
B
Error
-
C
{'x': int}
-
D
{'x': <class 'int'>, 'return': <class 'int'>}
Correct answer
Correct answer
D. {'x': <class 'int'>, 'return': <class 'int'>}
6 views
Explanation
__annotations__ stores parameter and return annotations.
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ