title: NameError undefined in Python function
body: <p>I want to calculate the area under a curve with an integral (Riemann). I wrote some code but it's giving me problems when I run it: <code>NameError: name 'y' is not defined</code>.</p>
  
  <p>This is the code:</p>
  
  <pre><code>from math import *
  
  def f(x):
     return y**2
  
  def integral (A, B, Rectangulos):
      ancho = (float(B) - float(A)) / Rectangulos
      suma = 0
      for i in range(Rectangulos):
         altura = f(A + i * ancho)
         area = altura * ancho
         suma = suma + area
      return suma
  
  A = int(input("Asigna el valor de A:  "))
  B = int(input("Asigna el valor de B:  "))
  
  Rectangulos = int(input("Indique la cantidad de rectangulos que desea utilizar \n (Recuerde que mientras mayor sea la densidad, el valor final sera mas cercano al valor deseado):  "))
  
  print ("El valor aproximado de esta integral es ", integral(A,B,Rectangulos))
  </code></pre>
  
  <p>How can I solve this error?</p>