title: object of type 'filter' has no len()
body: <p>i'm trying to use the simulation of monte carlo in order to calculate the area under the curve  (python 3.8)
  <a href="https://i.stack.imgur.com/1YLFZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1YLFZ.png" alt="enter image description here" /></a></p>
  <p><strong>in order to get this plot eventually</strong>
  <a href="https://i.stack.imgur.com/PSzc5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PSzc5.png" alt="enter image description here" /></a></p>
  <p>i tried this code</p>
  <pre><code>import random, math
  
  NUM_POINTS = 10000
  
  # Function for which we want to find area from (x=0 to 10).
  f = lambda x: 5 * math.sin(6 * x) + 3 * math.sin(2 * x) + 7
  
  # Sample rectangle will be (x,y) such that 0 &lt;= x &lt;= 10 and 0 &lt;= y &lt;= 14.
  rect_width = 10
  rect_height = 14
  
  # Funcitions to generate samples for x and y respectively.
  rand_x = lambda: random.uniform(0, rect_width)
  rand_y = lambda: random.uniform(0, rect_height)
  
  # Generate random sample points.
  points = [(rand_x(), rand_y()) for i in range(NUM_POINTS)]
  
  # Find points under our function
  points_under = filter(lambda point: point[1] &lt;= f(point[0]), points)
  
  # Area = area of domain rectangle * num_points_under/num_points_total
  area = rect_width * rect_height * len(points_under)*1.0/len(points)
  print (&quot;Estimate of area under the curve:&quot;, area)
  </code></pre>
  <p>i'm having this error :</p>
  <blockquote>
  <p>object of type 'filter' has no len()</p>
  </blockquote>
  <p>can anyone help me please ?</p>