Menu Close

Sum of Sine Series in Python3….FTC

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

Input:
Value of X in degrees:  30
Number of terms:  10

Output:
Sum of Sine Series:  0.5
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("Value of X in degrees: "))
n=int(input("Number of  terms: "))
print("\nSum of Sine Series: ",round(sin(x,n),2))


INPUT_1:
Value of X in degrees:  30
Number of terms:  10

OUTPUT:
Sum of Sine Series:  0.5


INPUT_2:
Value of X in degrees:  15
Number of terms:  10

OUTPUT:
Sum of Sine Series:  0.26


INPUT_3:
Value of X in degrees:  60
Number of terms:  5

OUTPUT:
Sum of Sine Series:  0.87


ILLUSTRATION

Executed using python3