def f(x):
    return(2-x**2)

def rect(n,a,b):
    s=0
    S=0
    h=(b-a)/n
    for k in range (n):
        s=s+f(a+k*h)*h
    for k in range (1,n+1):
        S=S+f(a+k*h)*h
    return (S, "<I<",s)

print(rect(4,0,1))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: