Return the value-to-weight ratio for the item. Returns: float: The value-to-weight ratio for the item. Examples: >>> Item(10, 65).ratio 6.5 >>> Item(20, 100).ratio 5.0 >>> Item(30, 120).ratio 4.0
(self)
| 11 | |
| 12 | @property |
| 13 | def ratio(self) -> float: |
| 14 | """ |
| 15 | Return the value-to-weight ratio for the item. |
| 16 | |
| 17 | Returns: |
| 18 | float: The value-to-weight ratio for the item. |
| 19 | |
| 20 | Examples: |
| 21 | >>> Item(10, 65).ratio |
| 22 | 6.5 |
| 23 | |
| 24 | >>> Item(20, 100).ratio |
| 25 | 5.0 |
| 26 | |
| 27 | >>> Item(30, 120).ratio |
| 28 | 4.0 |
| 29 | """ |
| 30 | return self.value / self.weight |
| 31 | |
| 32 | |
| 33 | def fractional_cover(items: list[Item], capacity: int) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected