mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-26 00:19:47 +00:00
add final else-statement
This commit is contained in:
parent
0ee8f792e3
commit
730cf6d173
@ -42,6 +42,8 @@ def electric_power(voltage: float, current: float, power: float) -> Tuple:
|
||||
return result("current", power / voltage)
|
||||
elif power == 0:
|
||||
return result("power", float(round(abs(voltage * current), 2)))
|
||||
else:
|
||||
raise ValueError("Exactly one argument must be 0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -32,6 +32,8 @@ def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, flo
|
||||
return {"current": voltage / resistance}
|
||||
elif resistance == 0:
|
||||
return {"resistance": voltage / current}
|
||||
else:
|
||||
raise ValueError("Exactly one argument must be 0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user