lista3q8-seno2.py
Click here to get the file
Size
1 kB
-
File type
text/python-source
File contents
import math #importando a biblioteca math
x = float(input("Digite o valor de x em graus: "))
n = int(input("Digite o valor de n (qtde de termos): "))
seno = 0.0
#convertendo x de graus para radianos:
x = math.pi*x/180
for i in range(n):
#calculando o termo "i":
a = i*2 +1
#calculando fatorial de um numero "a"
fat = 1
for p in range(a, 1, -1):
fat *= p
seno += (x**a)*((-1)**i)/fat
print("O valor do seno e: ", seno)