>>> potential_energy(10,10) 980.665 >>> potential_energy(0,5) 0.0 >>> potential_energy(8,0) 0.0 >>> potential_energy(10,5) 490.3325 >>> potential_energy(0,0) 0.0 >>> potential_energy(2,8) 156.9064 >>> potential_energy(20,100) 19613.3
(mass: float, height: float)
| 29 | |
| 30 | |
| 31 | def potential_energy(mass: float, height: float) -> float: |
| 32 | # function will accept mass and height as parameters and return potential energy |
| 33 | """ |
| 34 | >>> potential_energy(10,10) |
| 35 | 980.665 |
| 36 | >>> potential_energy(0,5) |
| 37 | 0.0 |
| 38 | >>> potential_energy(8,0) |
| 39 | 0.0 |
| 40 | >>> potential_energy(10,5) |
| 41 | 490.3325 |
| 42 | >>> potential_energy(0,0) |
| 43 | 0.0 |
| 44 | >>> potential_energy(2,8) |
| 45 | 156.9064 |
| 46 | >>> potential_energy(20,100) |
| 47 | 19613.3 |
| 48 | """ |
| 49 | if mass < 0: |
| 50 | # handling of negative values of mass |
| 51 | raise ValueError("The mass of a body cannot be negative") |
| 52 | if height < 0: |
| 53 | # handling of negative values of height |
| 54 | raise ValueError("The height above the ground cannot be negative") |
| 55 | return mass * g * height |
| 56 | |
| 57 | |
| 58 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected