标签:sum app pen print python highlight pytho [] range
奇数偶数以及差
odd = [] for i in range(1,101): if i % 2 != 0 : odd.append(i) print(odd) even = [] for i in range(1,101): if i % 2 == 0: even.append(i) print(even) sum1 = 0 for a in odd: sum1 = sum1 + a print(sum1) sum2 = 0 for a in even: sum2 = sum2 + a print(sum2) print(sum1 - sum2)
标签:sum app pen print python highlight pytho [] range
原文地址:https://www.cnblogs.com/xuwenwei/p/9589145.html