“”"
练习1:累加1–100之间整数
练习2:累加5–58之间整数
练习3:累加6–20之间偶数
练习4:累加10–50之间整数之间个位数是2、5、8的整数
“”"
练习1
sum = 0
for i in range(1, 101):
sum += i
print(sum)
练习2
sum2 = 0
for i in range(5, 59):
sum2 += i
print(sum2)
练习3
sum3 = 0
for i in range(6, 20):
if i % 2 == 0:
sum3 += i
print(sum3)
练习4
sum4 = 0
for i in range(10, 51):
if i % 10 == 2 or i % 10 == 5 or i % 10 == 8:
sum4 += i
print