Skip to main content

Practice ยท 1 of 1

Protocol-based area total

Implement: 1. class Area(Protocol) with one method area(self) -> float (use ... as the body). 2. total_area(shapes) summing s.area() over any objects that satisfy the protocol structurally (no isinstance gate โ€” just call area()). 3. parse(value) with two @overload stubs (str -> list, bytes -> str) and an implementation: bytes decode to str, str splits on ',' into a list.

Difficulty: advanced

Back to lesson: Practice: Protocols & Overloads Practice