In [22]:
def multiply(end):
    i=0
    s=1
    while i<end:
        i=i+1
        s=s*i
    return s

m = int(input('请输入第1个整数,以回车结束。'))
n = int(input('请输入第2个整数,以回车结束。'))
k = int(input('请输入第3个整数,以回车结束。'))
print('最终结果是:',multiply(m)+multiply(n)+multiply(k))


请输入第1个整数,以回车结束。3
请输入第2个整数,以回车结束。4
请输入第3个整数,以回车结束。5
最终结果是: 150

In [23]:
def compute_sum(n):
    i=0
    total=0
    while i<n:
        i=i+1
        total=total+1/(2*i-1)
    return total

n=1000
print('最终结果是:',4*compute_sum(n))
n=100000
print('最终结果是:',4*compute_sum(n))


最终结果是: 17.742530693340424
最终结果是: 26.952870981991452

In [35]:
def birth(birth_month,birth_day):
    if birth_month==12:
        if birth_day>21:
            print('您是摩羯座')
        else:
            print('你是射手座')
    if birth_month==11:
        if bitrh_day>22:
            print('你是射手座')
        else:
            print('你是天蝎座')
    if birth_month==10:
        if birth_day>23:
            print('您是天蝎座')
        else:
            print('您是天秤座')
    if birth_month==9:
        if birth_day>22:
            print('您是天秤座')
        else:
            print('您是处女座')
    if birth_month==8:
        if bitrh_day>22:
            print('您是处女座')
        else:
            print('您是狮子座')
    if birth_month==7:
        if birth_day>22:
            print('您是狮子座')
        else:
            print('您是巨蟹座')
    if birth_month==6:
        if birth_day>22:
            print('你是巨蟹座')
        else:
            print('您是双子座')
    if birth_month==5:
        if birth_day>20:
            print('您是双子座')
        else:
            print('您是金牛座')
    if birth_month==4:
        if birth_day>19:
            print('您是金牛座')
        else:
            print('您是白羊座')
    if birth_month==3:
        if birth_day>20:
            print('您是白羊座')
        else:
            print('您是双鱼座')
    if birth_month==2:
        if birth_day>18:
            print('您是双鱼座')
        else:
            print('您是水瓶座')
    if birth_month==1:
        if birth_day>19:
            print('您是水瓶座')
        else:
            print('您是摩羯座')
   
name=input('请输入您的姓名,以回车结束')
print('Hello',name)
birth_month=int(input('请输入您的出生月份,以回车结束'))
birth_day=int(input('请输入您的出生日期,以回车结束'))
birth(birth_month,birth_day)


请输入您的姓名,以回车结束zwn
Hello zwn
请输入您的出生月份,以回车结束10
请输入您的出生日期,以回车结束24
您是天蝎座

In [37]:
def compute(some_string):
    if some_string=='photo'or some_string=='piano':
        print('在词尾加s')
    elif some_string.endswith('s')or some_string.endswith('x')or some_string.endswith('o')or some_string.endswith('sh')or some_string.endswith('ch'):
        print('在词尾加es')
    elif some_string.endswith('y'):
        print('变y为i加es')
    elif some_string.endswith('f')or some_string.endswith('fe'):
        print('变f或fe为v,再加es')
    else:
        print('在词尾加s')


some_string=input('请输入一个单数单词')
compute(some_string)


请输入一个单数单词watch
在词尾加es

In [34]:
def compute_sum(m,n):
    k=n-m
    i=0
    while i<k:
        i=i+1
        m=n-k+m+i
    return m

m = int(input('请输入第1个整数,以回车结束。'))
n = int(input('请输入第2个整数,以回车结束。'))
print('最终结果是:',compute_sum(m,n))


请输入第1个整数,以回车结束。4
请输入第2个整数,以回车结束。6
最终结果是: 15