def integrate(func, interval=None, rects=100000):
    """
    Returns the result of the integral from the inclusive
    interval (a, b) using a Riemann sum approximation

    """
    if interval is None or not isinstance(interval, tuple):
        interval = eval(input('Interval (a, b): '))
    a, b = interval
    if a > b:
        print('note: the calculated area will be negative')
    if b - a > rects:
        rects = b - a
    area = 0
    x = a
    dx = (b - a) / rects
    for n in range(rects):
        try:
            area += func(x) * dx
        except Exception as e:
            print('Error:', e)
        x += dx
    return area