Sine series
Problem Description
Python Program to Find the Sum of Sine Series
Input
First Line : The value of x in degrees
Second Line: The number of terms
Output
Print the Sum of Sine series
CODING ARENA
import math
def sin(x,n):
sine = 0
for i in range(n):
sign = (-1)**i
pi=22/7
y=x*(pi/180)
sine = sine + ((y**(2.0*i+1))/math.factorial(2*i+1))*sign
return sine
x=int(input())
n=int(input())
print(round(sin(x,n),2))
Test Case 1
Input (stdin)30
10
Expected Output
0.5
Test Case 2
Input (stdin)45
14
Expected Output
0.71
No comments:
Post a Comment