每日练习②:get_sum

'''
def get_sum(a,b):

    #写代码, 输出结果

    # get_sum(1, 0) == 1   // 1 + 0 = 1
    # get_sum(1, 2) == 3   // 1 + 2 = 3
    # get_sum(0, 1) == 1   // 0 + 1 = 1
    # get_sum(1, 1) == 1   // 1 Since both are same
    # get_sum(-1, 0) == -1 // -1 + 0 = -1

    # get_sum(-1, 2) == 2  // -1 + 0 + 1 + 2 = 2

'''
def get_sum(a,b):
    return sum(range(min(a, b),max(a, b)+1))

res = get_sum(3,-8)
print(res)

 

posted @ 2018-07-20 23:46  q1ang  阅读(227)  评论(0编辑  收藏  举报