from drawtool import DrawTool import random import math dt = DrawTool() # Notice: x ranges between 0 and 3.141, y ranges between 0 and 1. dt.set_XY_range(0,3.141, 0,1) dt.set_aspect('equal') random.seed(123) # This draws the sin function. x = 0 m = 100 interval = 3.141/m dt.set_color('k') for i in range(m): y = math.sin(x) dt.draw_point(x,y) x += interval # Generate n=1000 random points. n = 1000 # Count how many of them have their y value below sin(x) count = 0 # Write your code here print('area estimate =', (count/n)*3.141) print('what theory predicts:', 2) dt.display()