鉴于100题太多,不可能只放在一篇博客里,也没有那么多的时间一把撸完,所以还是打算拆开来慢慢更新补充
q1、一行代码实现1–100之和
sum_100 = sum(range(1, 101))
print(sum_100)
print("range(1, 101): {}".format(type(range(1, 101))))
# 在python 3 中 range 返回的是一个 可迭代对象(类)
# sum 函数 sum(iterable, start)
# The sum() function adds the items of an iterable and returns the sum.
# iterable - iterable (list, tuple, dict, etc). The items of the iterable should be numbers.
# start (optional) - this value is added to t