In [1]:
def compute_pro(end):
    i = 0
    n = 1

    while i < end:
        i = i + 1 
        n = n * i
    return n


n = int(input('请输入第1个整数,以回车结束。'))
m = int(input('请输入第2个整数,以回车结束。'))
k = int(input('请输入第3个整数,以回车结束。'))

print('最终的积为:',compute_pro(n)+compute_pro(m)+compute_pro(k))


请输入第1个整数,以回车结束。5
请输入第2个整数,以回车结束。3
请输入第3个整数,以回车结束。2
最终的积为: 128

In [2]:
def compute_sum(end):
    i = 0
    m = 1
    total_n = 0

    while i < end:
        i = i + 1
        m = m + 2
        if i % 2 != 0 :
            total_n = total_n + 1/m
        else :
            total_n = total_n - 1/m

    return total_n

m = 1000
n = 10000 

print('n=1000时,结果为:', compute_sum(m) * 4)
print('m=100000时,结果为:', compute_sum(n) * 4)


n=1000时,结果为: 0.8574083456604576
m=100000时,结果为: 0.858307356409462

In [4]:
def wordends(word) :
    if word.endswith('x') or word.endswith('ch'):
        print(word,'es',sep='')
    else:
        print(word,'s',sep='')
        
        
word = input('请输入一个单词:')
wordends(word)


请输入一个单词:box
boxes

In [9]:
def constellation(birthday) :
    if(birthday>=3.21 and birthday<=4.19) :
        con= '白羊座'
    elif(birthday>=4.20 and birthday<=5.20) :
        con= '金牛座'
    elif(birthday>=5.21 and birthday<=6.21) :
        con= '双子座'
    elif(birthday>=6.22 and birthday<=7.22) :
        con= '巨蟹座'
    elif(birthday>=7.23 and birthday<=8.22) :
        con= '狮子座'
    elif(birthday>=8.23 and birthday<=9.22) :
        con= '处女座';
    elif(birthday>=9.23 and birthday<=10.23) :
        con= '天秤座';
    elif(birthday>=10.24 and birthday<=11.22) :
        con= '天蝎座';
    elif(birthday>=11.23 and birthday<=12.21) :
        con= '射手座';
    elif(birthday>=12.22 and birthday<=1.19) :
        con= '魔羯座';
    elif(birthday>=1.20 and birthday<=2.18) :
        con= '水平座';
    elif(birthday>=2.19 and birthday<=3.20) :
        con= '双鱼座'
        
    return con
        
name = input('请输入用户姓名,以回车结束:')
birthday = float(input('请输入生日(如8.04),以回车结束:'))

print(name,',你是非常有性格的',constellation(birthday),'!')


请输入用户姓名,以回车结束:william
请输入生日(如8.04),以回车结束:11.21
william ,你是非常有性格的 天蝎座 !

In [10]:
def compute_pro(front,end,interval) :
    total = 0
    a = 0
    
    if (front > end) :
        a = front
        front = end
        end = a
    while(front <= end) :
        total = total + front 
        front = front + interval
        
    return total

m = int(input('请输入第1个整数,以回车结束。'))
n = int(input('请输入第2个整数,以回车结束。'))
k = int(input('请输入整数间的间隔,以回车结束。'))

print('累加的和为:',compute_pro(m,n,k))


请输入第1个整数,以回车结束。3
请输入第2个整数,以回车结束。15
请输入整数间的间隔,以回车结束。2
累加的和为: 63