title: Write a program to compute the Taylor Series.
body: <p>I am new to python and don't understand how to use the libraries properly. I am trying to write a program to compute the Taylor Series Approximation  of a function centered at 0 at a given x and n.</p>
  
  <pre><code>def fact(n):    #function to calculate n!
  if n &lt;= 0:
      return 1
  else:
      return n * fact(n - 1)
  
  #h= 0.00000000001
  
  #def derivative(f,x,n):    #function that calculates the derivative of a 
   function at a specified x
      # return (f(x + h) - f(x - h)) /(2 * h)
  
   from sympy import *
   x = symbols('x')
  
  
  def taylor(f,x,n):    
      for i in range(0,n):
        t = 0
        t = t + ((diff(f,x,n))/(fact(n))) * (x ** n)
        return t
  
    taylor(sin(x),1/32,1)
  </code></pre>