1)、加法计算器
sum = 0
content = input('请输入内容')
l = content.split('+')
for i in l:
sum += int(i.strip()) #可不加strip,因为int可以去掉空格
print(sum)
2)、1-2+3-4+。。。。。+99求和
sum = 0
for i in range(1,100):
if i % 2 == 0:
sum += i
else:
sum -= i
i += 1
print(sum)
3)、求输入内容索引为奇数且为数字的个数
content = input('请输入内容')
j = 0
k = 0
for i in content:
if content.find(i) % 2 == 1 and i.isdigit():
j += 1
for i in range(len(content)):
if i % 2 == 1 and content[i].isdigit():
k += 1
print(j,k)