After execute test.py
This commit is contained in:
Binary file not shown.
Binary file not shown.
Regular → Executable
+7
-10
@@ -1,11 +1,8 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
def factorial(x):
|
def factorial(x):
|
||||||
ans = 1
|
ans = 1
|
||||||
|
if x < 0:
|
||||||
if x < 0:
|
raise ValueError('x must be greater than 0')
|
||||||
raise ValueError('x must be greater than 0')
|
for i in range(1, x+1):
|
||||||
|
ans *= i
|
||||||
for i in range(1, x+1):
|
return ans
|
||||||
ans *= i
|
|
||||||
|
|
||||||
return ans
|
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
from trigonometry import sin
|
from trigonometry import sin
|
||||||
import math
|
import math
|
||||||
|
|
||||||
pi = math.pi
|
pi = math.pi
|
||||||
print('pi:', pi)
|
print('pi:', pi)
|
||||||
for alpha in [0, pi, pi/2, pi/3, pi/4, pi/6]:
|
for alpha in [0, pi, pi/2, pi/3, pi/4, pi/6]:
|
||||||
print(f'For angle: {0 if alpha == 0 else "pi/"+str(int(pi/alpha))}, Sine is ~ {sin(alpha)}')
|
print(f'For angle: {0 if alpha == 0 else "pi/"+str(int(pi/alpha))}, Sine is ~ {sin(alpha)}')
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
from factorial import factorial as fct
|
from factorial import factorial as fct
|
||||||
|
|
||||||
def sin(x):
|
def sin(x):
|
||||||
sin = 1 - (x**2/fct(2)) + (x**4/fct(4)) - (x**6/fct(6)) + (x**8/fct(8)) - (x**10/fct(10))
|
sin = 1 - (x**2/fct(2)) + (x**4/fct(4)) - (x**6/fct(6)) + (x**8/fct(8)) - (x**10/fct(10))
|
||||||
return round(sin, 5)
|
return round(sin, 5)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user