sum、计算和,此函数传入的参数是list
L = [] x = 1 while x <= 100: L.append(x * x) x = x + 1 print sum(L)
cmp、对比两个数的大小
>>> cmp(1, 2) -1 >>> cmp(2, 1) 1 >>> cmp(3, 3) 0
abs、绝对值
>>> abs(100) 100 >>> abs(-20) 20 >>> abs(12.34) 12.34
sum、计算和,此函数传入的参数是list
L = [] x = 1 while x <= 100: L.append(x * x) x = x + 1 print sum(L)
cmp、对比两个数的大小
>>> cmp(1, 2) -1 >>> cmp(2, 1) 1 >>> cmp(3, 3) 0
abs、绝对值
>>> abs(100) 100 >>> abs(-20) 20 >>> abs(12.34) 12.34