title: pass user input as lambda function
body: <p>I'm learning python and I'm not sure how to pass a string to lambda.</p>
  
  <p>This is a basic example of Riemann sum:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import numpy as np
  #f0 = str(input("ingrese funcion:"))
  f = lambda x: x**2
  sum = 0.0
  a = float(input("ingrese límite inferior:"))
  b = float(input("ingrese límite superior:"))
  n = int(input("ingrese cantidad de subintervalos:"))
  i = b-a #la longitud del intervalo
  dx = i/n #que diferencia habrá cada vez que evalúes
  for xi in np.arange(a,b,dx):
      sum += dx*f(xi)
  print "Valor de la suma de Riemann de f en [a,b] = " + str(sum)
  </code></pre>
  
  <p>My idea was to let <code>f0</code> as a user defined string (e.g. <code>x**2 + 10</code>) and then pass <code>f0</code> to <code>f</code>. Of course doing that should return an "undefined" error.</p>