单选题

下列程序段中自定义函数do(n)的作用是?( )

def do(n):
    s=0
    f=1
    for i in range(1,n+1,2):
        s=s+1/i*f
        f=-f
    return s
print(do(10))


A

求1+1/2+1/3+1/4+1/5+1/6+1/7+1/8+1/9+1/10的值

B

求1+1/3+1/5+1/7+1/9的值

C

求1-1/3+1/5-1/7+1/9-1/10的值

D

求1-1/3+1/5-1/7+1/9的值

赣ICP备20007335号-2