In [ ]:
def compute_sum(end):
i = 1
total_m = 1
while end > i:
i = i+1
total_m = total_m * i
return total_m
m = int(input('请输入第1个整数'))
n = int(input('请输入第2个整数'))
k = int(input('请输入第3个整数'))
print('最终的和是:', compute_sum(m) + compute_sum(n) + compute_sum(k))
In [1]:
def compute_sum(end):
t = 0
i = 1
total_n = 1
while t < end:
i = i + 2
t = t + 1
total_n = total_n + (-1)**t * 1/i
return total_n
n = 1000
print('4倍前1000项的和为:', 4*compute_sum(n))
n = 100000
print('4倍前100000项的和为:', 4*compute_sum(n))
In [ ]:
name = input('请输入你的姓名,以回车结束')
print('你好', name)
def compute_star(d):
if m == 4:
if d < 20:
j = '你是白羊座'
else:
j = '你是非常有性格的金牛座'
return j
m = int(input('请输入你的出生月份'))
d = int(input('请输入你的出生日期'))
print(computer_star(d))
In [ ]: