@@ -23,20 +23,22 @@ 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 ...
3434 ValueError: Power cannot be negative in any electrical/electronics system
3535 >>> electric_power(voltage=2.2, current=2.2, power=0)
3636 Result(name='power', value=4.84)
37+ >>> electric_power(current=0, power=6, voltage=2)
38+ Result(name='current', value=3.0)
3739 """
3840 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" )
4042 elif power < 0 :
4143 raise ValueError (
4244 "Power cannot be negative in any electrical/electronics system"
@@ -48,7 +50,7 @@ def electric_power(voltage: float, current: float, power: float) -> tuple:
4850 elif power == 0 :
4951 return Result ("power" , float (round (abs (voltage * current ), 2 )))
5052 else :
51- raise ValueError ( "Exactly one argument must be 0" )
53+ raise AssertionError
5254
5355
5456if __name__ == "__main__" :
0 commit comments