In [3]:
def fun(n):
    i=1
    total=1
    while i<=n:
        total=total*i
        i+=1
    return total

m=int(input('请输入第一个整数:'))
n=int(input('请输入第二个整数:'))
k=int(input('请输入第三个整数:'))
total1=fun(m)
total2=fun(n)
total3=fun(k)
print(total1+total2+total3)


请输入第一个整数:3
请输入第二个整数:2
请输入第三个整数:4
32

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

print(4*fun(1000))
print(4*fun(10000))


4.0
3.1414926535900345

In [13]:
def fun(date):
    if 3.21<=date<=4.19:
        print(name,'你是非常有性格的白羊座')
    elif 4.20<=date<=5.20:
        print(name,'你是非常有性格的金牛座')
    elif 5.21<=date<=6.21:
        print(name,'你是非常有性格的双子座')
    elif 6.22<=date<=7.22:
        print(name,'你是非常有性格的巨蟹座')
    elif 7.23<=date<=8.22:
        print(name,'你是非常有性格的狮子座')
    elif 8.23<=date<=9.22:
        print(name,'你是非常有性格的处女座')
    elif 9.23<=date<=10.23:
        print(name,'你是非常有性格的天秤座')
    elif 10.24<=date<=11.22:
        print(name,'你是非常有性格的天蝎座')
    elif 11.23<=date<=12.21:
        print(name,'你是非常有性格的射手座')
    elif 12.22<=date<=12.31 or 1.1<=date<=1.19:
        print(name,'你是非常有性格的摩羯座')
    elif 1.20<=date<=2.18:
        print(name,'你是非常有性格的水瓶座')
    else:
        print(name,'你是非常有性格的双鱼座')

name=input('请输入你的名字:')
date=float(input('请输入你的生日(例如3.26):')
fun(date)


  File "<ipython-input-13-62952a306703>", line 29
    fun(date)
      ^
SyntaxError: invalid syntax

In [22]:
def fun(word):
    if word.endswith('ch') or word.endswith('sh')or word.endswith('s') or word.endswith('x') or word.endswith('o') or word.endswith('z'):  
        return word+'es'
    elif word.endswith('by') or word.endswith('cy') or word.endswith('dy') or word.endswith('fy') or word.endswith('gy') or word.endswith('hy') or word.endswith('jy') or word.endswith('ky') or word.endswith('ly') or word.endswith('my') or word.endswith('ny') or word.endswith('py') or word.endswith('qy') or word.endswith('ry') or word.endswith('sy') or word.endswith('ty') or word.endswith('wy') or word.endswith('xy') or word.endswith('zy'):
        return word[:-1]+'ies'    
    elif word.endswith('f'):
        return word[:-1]+'ves'
    elif word.endswith('fe'):
        return word[:-2]+'ves'
    else:
        return word+'s'
        
        
word=input('请输入一个英文单词')
m=fun(word)
print(m)


请输入一个英文单词fly
flies

In [12]:
def fun(m,n,k):
    i=m
    total=0
    while i<=n:
        total=total+i
        i+=k
    
    return total
    
    
m=int(input('请输入第一个整数:'))
n=int(input('请输入第二个整数(大于第一个数):'))
k=int(input('请输入您想要的间隔:'))
print(fun(m,n,k))


请输入第一个整数:3
请输入第二个整数(大于第一个数):10
请输入您想要的间隔:2
24