Code Annotations
Code Annotations
def calculate_area(radius: float) -> float: # (1)!
"""Calculate the area of a circle."""
import math # (2)!
return math.pi * radius ** 2 # (3)!
- Type hints improve code readability
- Import inside function for demonstration
- Uses the formula: A = pi * r^2