Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 951a3a2

Browse files
authoredDec 27, 2024··
Update electric_power.py
1 parent f819ab9 commit 951a3a2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎electronics/electric_power.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
2323
>>> electric_power(voltage=2, current=4, power=2)
2424
Traceback (most recent call last):
2525
...
26-
ValueError: Only one argument must be 0
26+
ValueError: Exactly one argument must be 0
2727
>>> electric_power(voltage=0, current=0, power=2)
2828
Traceback (most recent call last):
2929
...
30-
ValueError: Only one argument must be 0
30+
ValueError: Exactly one argument must be 0
3131
>>> electric_power(voltage=0, current=2, power=-4)
3232
Traceback (most recent call last):
3333
...
@@ -38,7 +38,7 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
3838
Result(name='current', value=3.0)
3939
"""
4040
if (voltage, current, power).count(0) != 1:
41-
raise ValueError("Only one argument must be 0")
41+
raise ValueError("Exactly one argument must be 0")
4242
elif power < 0:
4343
raise ValueError(
4444
"Power cannot be negative in any electrical/electronics system"
@@ -49,8 +49,6 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
4949
return Result("current", power / voltage)
5050
elif power == 0:
5151
return Result("power", float(round(abs(voltage * current), 2)))
52-
else:
53-
raise ValueError("Exactly one argument must be 0")
5452

5553

5654
if __name__ == "__main__":

0 commit comments

Comments
 (0)
Please sign in to comment.