In [1]:
#练习1
def compute_sum(end):
    i=0
    total_n=1
    
    while i<end:
        i=i+1
        total_n=total_n*i
        
    return total_n

n=int(input('输入一个整数'))
m=int(input('输入一个整数'))
k=int(input('输入一个整数'))

print('total', compute_sum(m)+compute_sum(n)+compute_sum(k))


plz2
plz3
plz1
5

In [ ]:
#练习2
def compute_sum(n):
    i=1
    total=0
    while i<=n:
        total=1/(2*i-1)-1/(2*i+1)+total
        i=i+2
    return total
        
n=int(input('请输入一个整数'))
print(compute_sum(n)*4)

In [ ]:
#练习3 
#task 3 练习1
def n(date):
    if 1.20<=date<=2.18:
        return('水瓶座')
    if 2.19<=date<=3.20:
        return('双鱼座')
    if 3.21<=date<=4.19:
        return('白羊座')
    if 4.20<=date<=5.20:
        return('金牛座')
    if 5.21<=date<=6.21:
        return('双子座')
    if 6.22<=date<=7.22:
        return('巨蟹座')
    if 7.23<=date<=8.22:
        return('狮子座')
    if 8.23<=date<=9.22:
        return('处女座')
    if 9.23<=date<=10.23:
        return('天秤座')
    if 10.24<=date<=11.22:
        return('天蝎座')
    if 11.23<=date<=12.21:
        return('射手座')
    if 12.22<=date<=12.31 or 1.01<=date<=1.18:
        return('摩羯座')

date=float(input('请输入你的出生日期'))
print(n(date))

In [ ]:
#练习3
#task3 练习4
def plural(word):
    if word.endswith('x') or word.endswith('s') or word.endswith('sh') or word.endswith('ch'):
        return('es')
    else:
        return('s')

word=str(input('plz'))
print(plural(word))

In [ ]:
#挑战性练习
def compute_sum(m,n,k):
    total=m
    while m<n:
        m=m+k
        total=total+m
    return total


m=int(input('plz input'))
n=int(input('plz input'))
k=int(input('plz input'))
print(compute_sum(m,n,k))