Add '^' exponentiation alias to calculate and tests
This commit is contained in:
+4
-2
@@ -1,7 +1,7 @@
|
||||
"""A small arithmetic calculator.
|
||||
|
||||
Provides the :func:`calculate` function which performs basic arithmetic
|
||||
operations (+, -, *, /, **, //, %) with proper error handling.
|
||||
operations (+, -, *, /, **, ^, //, %) with proper error handling.
|
||||
"""
|
||||
|
||||
__all__ = ["calculate"]
|
||||
@@ -17,7 +17,7 @@ def calculate(a: float, op: str, b: float) -> int | float:
|
||||
|
||||
Args:
|
||||
a: First operand
|
||||
op: Operation (+, -, *, /, **, //, %)
|
||||
op: Operation (+, -, *, /, **, ^, //, %)
|
||||
b: Second operand
|
||||
|
||||
Returns:
|
||||
@@ -50,6 +50,8 @@ def calculate(a: float, op: str, b: float) -> int | float:
|
||||
return a / b
|
||||
case "**":
|
||||
return a ** b
|
||||
case "^":
|
||||
return a ** b
|
||||
case "//":
|
||||
return a // b
|
||||
case "%":
|
||||
|
||||
Reference in New Issue
Block a user