In [4]:
def c(end):
    i=1
    a=1
    while i<=end:
        a=a*i
        i=i+1
    return(a)
n = int(input('请输入第1个整数,以回车结束。'))
m = int(input('请输入第2个整数,以回车结束。'))
k = int(input('请输入第3个整数,以回车结束。'))

print('最终的和是:', c(m) + c(n) + c(k))


请输入第1个整数,以回车结束。1
请输入第2个整数,以回车结束。2
请输入第3个整数,以回车结束。3
最终的和是: 9

In [ ]:
# 写函数可返回1 - 1/3 + 1/5 - 1/7...的前n项的和。在主程序中,分别令n=1000及100000,打印4倍该函数的和。
def total(n):
    i=1
    t=0.0
    while 1<=n:
        a=2*i-1
        if i/2==0:
            b=-float(1/a)
        else:
            b=float(1/a)
        t=t+b
        i=i+1
    return(t)
print(total(1000),4*total(10000))
print(total(10000),4*total(100000))

In [ ]:
print('please enter your name.')
a= str(input())
print('please enter your birth monthes')
b= int(input())
print('please enter your birth days')
c=int(input())
def hahaha(a,b,c):
    if b==1:
        if c<=20:
            print(a,'you are capricron')
        else:
            print(a,'you are aquarius')
    elif b==2:
        if c<=19:
            print(a,'you are aquarius')
        else:
            print(a,'you are pisces')
    elif b==3:
        if c<=21:
            print(a,'you are pisces')
        else:
            print(a,'you are aries')
    elif b==4:
        if c<=20:
            print(a,'you are aries')
        else:
            print(a,'you are taurus')
    elif b==5:
        if c<=22:
            print(a,'you are taurus')
        else:
            print(a,'you are gemini')
    elif b==6:
        if c<=21:
            print(a,'you are gemini')
        else:
            print(a,'you are cancer')
    elif b==7:
        if c<=22:
            print(a,'you are cancer')
        else:
            print(a,'you are leo')
    elif b==8:
        if c<=24:
            print(a,'you are leo')
        else:
            print(a,'you are virgo')
    elif b==9:
        if c<=23:
            print(a,'you are virgo')
        else:
            print(a,'libra')
    elif b==10:
        if c<=23:
            print(a,'you are libra')
        else:
            print(a,'you are scorpio')
    elif b==11:
        if c<=23:
            print(a,'you are scorpio')
        else:
            print(a,'you are sagittarius')
    else:
        if c<=21:
            print(a,'you are sagittariu')
        else:
            print(a,'you are capricron')
hahaha(a,b,c)

In [ ]:
print('please enter a word')
a=str(input())
def ha(a1):
    if(a1.endswith('s')):
        print(al,'es ')
    elif(a1.endswith('sh')):
        print(al,'es ')
    elif(a1.endswith('ch')):
        print(al,'es ')
    elif(a1.endswith('x')):
        print(al,'es ')
    elif(a1.endswith('y')):
        print('以辅音字母+y结尾 变y 为i再加es')
    else:
        print(al,'s')
ha(a)

In [ ]:
def buhuizuo(m,n,k):
    i=m
    total=0
    while i<n:
        total=total+i
        i=i+k+1
    return(i)
print('please enter the first number')
m=int(input())
print('please enter the second number')
n=int(input())
print('please enter the third number')
k=int(input())
print(buhuizuo(m,n,k))

In [ ]: