1、输出1-100偶数的和
def out_put():
sum = 0
for i in range(1, 101):
if i % 2 == 0:
sum += i
print(sum)
return sum
out_put()
2、编写函数,计算201918*…*3的结果
def out_put():
pod = 1
for i in range(3, 21):
pod *= i
print(pod)
return pod
out_put()
3、编写函数,计算(M)(M-1)(M-2)…(N+1)*(N)的结果
def out_put(m, n):
pod = 1
for i in range(n, m + 1):
pod *= i
print(pod)
return pod
out_put(21, 3)
4、编写用户输入的字符是不是回文字符串
str = '1234543215'
len_str = len(str)
flag = 1
for i in range(int(len_str/2)):
if str[i] != str[len_str-1-i]:
flag = 0
break
if flag == 1:
print('是')
else:
print('不是')