问: 计算100以内自然数中偶数的和
# 方法一 s = 0 for i in range(101): if i%2==0: s = s +i print(s) # 方法二 a = [] for i in range(101): if i%2==0: a.append(i) print(sum(a))
标签:python,练习,range,print,101,i% From: https://www.cnblogs.com/ayue6/p/17787091.html
问: 计算100以内自然数中偶数的和
# 方法一 s = 0 for i in range(101): if i%2==0: s = s +i print(s) # 方法二 a = [] for i in range(101): if i%2==0: a.append(i) print(sum(a))
标签:python,练习,range,print,101,i% From: https://www.cnblogs.com/ayue6/p/17787091.html