def midpointint(f, a, b, n):
    """
    Computes the Midpoint integration rule of f from a to b using a python for loop. 
    """
    running_sum = 0
    for i in range(n):
        running_sum += f(a + ((b-a)/float(n))*(i + .5) )
    return running_sum * (b-a)/float(n)