title: Python : name 'math' is not defined Error?
body: <p>I am a beginner in python and cant understand why this is happening:</p>
  
  <pre><code>from math import *
  print "enter the number"
  n=int(raw_input())
  d=2
  s=0
  while d&lt;n :
      if n%d==0:
         x=math.log(d)
         s=s+x
         print d
      d=d+1
  print s,n,float(n)/s   
  </code></pre>
  
  <p>Running it in Python and inputing a non prime gives the error </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\mit ocw\pset1a.py", line 28, in &lt;module&gt;
      x=math.log(d)
  NameError: name 'math' is not defined
  </code></pre>