def my_pow(x, n): # Base case: If the exponent is 0, return 1 if n == 0: return 1 # Handle negative exponents if n < 0: x = 1 / x n = -n result = 1 # Perform exponentiation using a loop for _ in range(n): result *= x return result # Test your custom pow function base = 2 exponent = 3 result = my_pow(base, exponent) print(f"{base}^{exponent} = {result}")