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

    while i < end:
        i = i + 1
        total_n = total_n * i

    return total_n

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

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


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

In [3]:
def compute_add(num):
    i = 0
    total = 0
    while i < num:
        j = 2 * i + 1
        i = i + 1
        if i%2 != 0:
            total = total + 1/j
        else:
            total = total - 1/j
    return total

m = int(input('请输入第一个整数,回车结束  '))
print ('4倍的和:tatol1 =',4*compute_add(m))
n = int(input('请输入第二个整数,回车结束  '))
print ('4倍的和:tatol2 =',4*compute_add(n))


请输入第一个整数,回车结束  1000
4倍的和:tatol1 = 3.140592653839794
请输入第二个整数,回车结束  10000
4倍的和:tatol2 = 3.1414926535900345

In [4]:
def constellation(name,month,day):
    if month > 12 or month < 1 or day < 1 or day > 31:
        print ('你输入的数字非法!')
    if (month == 3 and 21<=day<=31) or (month == 4 and 1<=day<=19):
        print (name,'你是非常有性格的白羊座!',sep = ',')
    elif (month == 4 and 20<=day<=30) or (month == 5 and 1<=day<=20):
        print (name,'你是非常有性格的金牛座!',sep = ',')
    elif (month == 5 and 21<=day<=31) or (month == 6 and 1<=day<=21):
        print (name,'你是非常有性格的双子座!',sep = ',')
    elif (month == 6 and 22<=day<=30) or (month == 7 and 1<=day<=22):
        print (name,'你是非常有性格的巨蟹座!',sep = ',')
    elif (month == 7 and 23<=day<=31) or (month == 8 and 1<=day<=22):
        print (name,'你是非常有性格的狮子座!',sep = ',')
    elif (month == 8 and 23<=day<=31) or (month == 9 and 1<=day<=22):
        print (name,'你是非常有性格的处女座!',sep = ',')
    elif (month == 9 and 23<=day<=30) or (month == 10 and 1<=day<=23):
        print (name,'你是非常有性格的天秤座!',sep = ',')
    elif (month == 10 and 24<=day<=31) or (month == 11 and 1<=day<=22):
        print (name,'你是非常有性格的天蝎座!',sep = ',')
    elif (month == 11 and 23<=day<=30) or (month == 12 and 1<=day<=21):
        print (name,'你是非常有性格的射手座!',sep = ',')
    elif (month == 12 and 22<=day<=31) or (month == 1 and 1<=day<=19):
        print (name,'你是非常有性格的魔蝎座!',sep = ',')
    elif (month == 1 and 20<=day<=31) or (month == 2 and 1<=day<=18):
        print (name,'你是非常有性格的水瓶座!',sep = ',')
    elif (month == 2 and 19<=day<=28) or (month == 3 and 1<=day<=20):
        print (name,'你是非常有性格的双鱼座!',sep = ',')
        
name = input('请输入你的姓名,回车结束  ')
month = int(input('请输入你生日的月份,回车结束  '))
day = int(input('请输入你生日的日号,回车结束  '))
constellation(name,month,day)


请输入你的姓名,回车结束  zxt
请输入你生日的月份,回车结束  12
请输入你生日的日号,回车结束  6
zxt,你是非常有性格的射手座!

In [7]:
def change(word):
    if word.endswith('s') or word.endswith('x') or word.endswith('sh') or word.endswith('ch'):
        print (word+'es')
    elif word.endswith('y'):
        print (word[0:len(word)-1]+'ies')
    else :
        print (word+'s')
        
while True :
    word = input('请输入一个要转换的英语单词,回车结束,输入‘回车’结束  ')
    if word == '回车':
        break
    change(word)


请输入一个要转换的英语单词,回车结束,输入‘回车’结束  book
books
请输入一个要转换的英语单词,回车结束,输入‘回车’结束  school
schools
请输入一个要转换的英语单词,回车结束,输入‘回车’结束  回车

In [8]:
def computer_sum(m,n,k):
    while m <= n:
        m += k
    return m

m = int(input('请输入第一个整数,回车结束  '))
n = int(input('请输入第二个整数,回车结束  '))
k = int(input('请输入第三个整数,回车结束  '))
print ('tatol =',computer_sum(m,n,k))


请输入第一个整数,回车结束  3
请输入第二个整数,回车结束  6
请输入第三个整数,回车结束  2
tatol = 7

In [ ]:


In [ ]:


In [ ]:


In [ ]: