Mathematics
Make a function to evaluate Euler's Formula for any value of x
import math
# Power series
def e_to_the_i(x):
return sum([(1j*x)**n/math.factorial(n) for n in range(25)])
import codewars_test as test
import math
# TODO Write tests
from solution import e_to_the_i
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
test.assert_approx_equals(e_to_the_i(math.pi), -1)
test.assert_approx_equals(e_to_the_i(1j), 1/math.e)