In [2]:
#求 m!+n!+k!


def compute_product(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(compute_product(n) + compute_product(m) + compute_product(k))


请输入第一个整数,以回车结束2
请输入第二个整数,以回车结束3
请输入第三个整数,以回车结束2
10

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

#主程序

n = 1000
m = 10000
k = 1000000
print(4*compute_sum(n), 4*compute_sum(m), 4*compute_sum(k))


3.140592653839794 3.1414926535900345 3.1415916535897743

In [2]:
def star(n):
    
    if 321 < n < 419:
        print('你是容易冲动的白羊座')
    if 420 < n < 520:
        print('你是真诚随和的金牛座')
    if 521 < n < 621:
        print('你是聪明活泼的双子座')
    if 622 < n < 722:
        print('你是感性善变的巨蟹座')
    if 723 < n < 822:
        print('你是高傲自大的狮子座')
    if 823 < n < 922:
        print('你是追求完美的处女座')
    if 923 < n < 1023:
        print('你是圆滑保守的天秤座')
    if 1024 < n < 1122:
        print('你是神秘莫测的天蝎座')
    if 1123 < n < 1221:
        print('你是乐观积极的射手座')
    if 1222 < n < 1231:
        print('你是踏实固执的摩羯座')
    if 101 < n < 120:
        print('你是踏实固执的摩羯座')
    if 120 < n < 219:
        print('你是求知欲强的水瓶座')
    if 220 < n < 320:
        print('你是的善良浪漫双鱼座')
        
#主程序
n = int(input('请输入你的出生日期,如0105。以回车结束'))
print(star(n))


请输入你的出生日期,如0105。以回车结束0105
你是踏实固执的摩羯座
None

In [3]:
def add(word):
    
    if word. endswith('e'):
        print(word,'s',sep='')
    
    if word. endswith('s'):
        print(wold,'es',sep='')
    
    if word. endswith('sh'):
        print(world,'es',sep='')
        
#主程序
word = input('请输入一个名词单数')
print(add(word))


请输入一个名词单数tree
trees
None