#计算1+2+3+……+100sum = 0num = 1while num <= 100: sum += num #1+……+99 + 100 num += 1print("sum = %d" % (sum))