Divides a by b. Raises: ValueError: When the inputs cannot be divided.
(a: float, b: float)
| 20 | # Check types in this file with: python3 -m mypy <path> |
| 21 | |
| 22 | def careful_divide(a: float, b: float) -> float: |
| 23 | """Divides a by b. |
| 24 | |
| 25 | Raises: |
| 26 | ValueError: When the inputs cannot be divided. |
| 27 | """ |
| 28 | try: |
| 29 | return a / b |
| 30 | except ZeroDivisionError: |
| 31 | raise ValueError("Invalid inputs") |
| 32 | |
| 33 | try: |
| 34 | result = careful_divide(1, 0) |
no outgoing calls
no test coverage detected