#題目:用range()來產生數字序列 #Python 程式碼如下 A=[i for i in range(10)] B=[i for i in range(1,10)] C=[i for i in range(1,10,3)] D=[i for i in range(10,-5,-1)] print("A=",A) print("B=",B) print("C=",C) print("D=",D) # 輸出結果如下:
A= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] B= [1, 2, 3, 4, 5, 6, 7, 8, 9] C= [1, 4, 7] D= [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]