100之內奇數:app
ls = [x for x in range(100) if x % 2 == 1]
spa
100之內偶數:code
ls = list(x for x in range(100) if x % 2 == 0)blog
20之內的2次方:ci
ls = list(x * x for x in range(20))
class
斐波那契數列 Fibonacci :
一、一、二、三、五、八、1三、2一、34 …… 數列特色:該數列從第三項開始,每一個數的值爲其前兩個數之和import
ls = [1, 1] for i in range(2, 20): ls.append(ls[i - 2] + ls[i - 1]) print(ls)
試一下:im
import copy a = True a = 123 a = "123" a = (1, 2, 3) a = [1, 2, 3] a = {"x":1,"y":2} b = copy.copy(a) c = copy.deepcopy(a) print(id(a)) print(id(b)) print(id(c))