title: TypeError: can't convert expression to float
body: <p>I am a python newbie. I am trying to evaluate Planck equation using python. I have written a simple program. But when I give input to it is giving me an error. can anyone hep me where I am going wrong? Here is the program and the error:</p>
  
  <p>Program:</p>
  
  <pre><code>from __future__ import division
  from sympy.physics.units import *
  from math import *
  import numpy
  from scipy.interpolate import interp1d
  
  #Planck's Law evaluation at a single wavelength and temperature
  def planck_law(wavelength,temperature):
      T=temperature
      f=c/wavelength
      h=planck
      k=boltzmann
      U=2*h/(c**3)*(f**3)/(exp(h*f/(k*T))-1)
      return U.evalf()
  </code></pre>
  
  <p>Input:
  I have imported the function as 'cp' and the input is as follows</p>
  
  <pre><code>value = (cp.planck_law(400,2000))
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;`enter code here`
    File "Camera_performance.py", line 14, in planck_law
    U=2*h/(c**3)*(f**3)/(exp(h*f/(k*T))-1)
    File "/usr/lib/python2.7/dist-packages/sympy/core/expr.py", line 221, in __float__
    raise TypeError("can't convert expression to float")
  
  TypeError: can't convert expression to float
  </code></pre>