@@ -23,11 +23,11 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
23
23
>>> electric_power(voltage=2, current=4, power=2)
24
24
Traceback (most recent call last):
25
25
...
26
- ValueError: Only one argument must be 0
26
+ ValueError: Exactly one argument must be 0
27
27
>>> electric_power(voltage=0, current=0, power=2)
28
28
Traceback (most recent call last):
29
29
...
30
- ValueError: Only one argument must be 0
30
+ ValueError: Exactly one argument must be 0
31
31
>>> electric_power(voltage=0, current=2, power=-4)
32
32
Traceback (most recent call last):
33
33
...
@@ -38,7 +38,7 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
38
38
Result(name='current', value=3.0)
39
39
"""
40
40
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" )
42
42
elif power < 0 :
43
43
raise ValueError (
44
44
"Power cannot be negative in any electrical/electronics system"
@@ -49,8 +49,6 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
49
49
return Result ("current" , power / voltage )
50
50
elif power == 0 :
51
51
return Result ("power" , float (round (abs (voltage * current ), 2 )))
52
- else :
53
- raise ValueError ("Exactly one argument must be 0" )
54
52
55
53
56
54
if __name__ == "__main__" :
0 commit comments