@@ -23,20 +23,22 @@ 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
...
34
34
ValueError: Power cannot be negative in any electrical/electronics system
35
35
>>> electric_power(voltage=2.2, current=2.2, power=0)
36
36
Result(name='power', value=4.84)
37
+ >>> electric_power(current=0, power=6, voltage=2)
38
+ Result(name='current', value=3.0)
37
39
"""
38
40
if (voltage , current , power ).count (0 ) != 1 :
39
- raise ValueError ("Only one argument must be 0" )
41
+ raise ValueError ("Exactly one argument must be 0" )
40
42
elif power < 0 :
41
43
raise ValueError (
42
44
"Power cannot be negative in any electrical/electronics system"
@@ -48,7 +50,7 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
48
50
elif power == 0 :
49
51
return Result ("power" , float (round (abs (voltage * current ), 2 )))
50
52
else :
51
- raise ValueError ( "Exactly one argument must be 0" )
53
+ raise AssertionError
52
54
53
55
54
56
if __name__ == "__main__" :
0 commit comments