實現1-100的全部的和排序
sum1 = 0 while sum1 < 100: sum1 += 1 print sum1 print ('-----' * 10)
實現1-500全部奇數的和sort
sum1 = 0 for i in xrange(1,501,2): sum1 += i print sum1
求1+ 2! + 3! + 4! + ……20!的和while
a = 1 b = 0 for i in range(1,21): a = a*i b = b + a print(b)
對指定一個list進行排序[2,32,43,453,54,6,576,5,7,6,8,78,7,89]
a = [2,32,43,453,54,6,576,5,7,6,8,78,7,89] a.sort() print(a)