Skip to main content

Practice · 1 of 1

Protocol-based area total

CHALLENGE
Difficulty: advanced+25 XP

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.

Back to lesson: Practice: Protocols & Overloads Practice