In: Computer Science
Create a Python function called eulersFormula that
returns the value of Euler's formula
e^(iπ) + 1
Python code for the problem is provided below, please comment if any doubts:
Note: The code may lost its indentation while copying, if so refer the screenshot to reconstruct the indentation:
Python code:
#math package to use pi and e in code
import math
#the function definition
def eulersFormula():
#find the value of eulers formula
Ef=math.e**(math.pi*1j)+1
#return the result by the function
return abs(Ef)
#test the function, by printing first ten decimal values
print("%.10f"%eulersFormula())
Output:
Code screenshot: