返回列表 發帖

range() 函式的練習

  1. #0~9 陣列 只丟一個參數的時候
  2. list1 = range(10)
  3. print("一個參數的range: ")
  4. print(list1[0])
  5. print(list1[9])
  6. #3~7 range(起始值,終止值)
  7. lisr2 = range(3,8)
  8. print("兩個參數的range: ")
  9. print(lisr2[0])
  10. print(lisr2[4])

  11. #range(起始值,終止值, 間隔值)
  12. #1 3 5 7 9
  13. print("三個參數的range: ")
  14. list3 = range(1,10,2)
  15. print(list3[4])
複製代碼

  1. list1 = range(12)
  2. print(list1[0])
  3. print(list1[8])
  4. lisr2 = range(3,10)
  5. print(lisr2[0])
  6. print(lisr2[6])
  7. list3 = range(1,14,4)
  8. print(list3[2])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])
  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. #0~9 陣列 只丟一個參數的時候
  2. list1 = range(10)
  3. print("一個參數的range: ")
  4. print(list1[0])
  5. print(list1[9])
  6. #3~7 range(起始值,終止值)
  7. lisr2 = range(3,8)
  8. print("兩個參數的range: ")
  9. print(lisr2[0])
  10. print(lisr2[4])

  11. #range(起始值,終止值, 間隔值)
  12. #1 3 5 7 9
  13. print("三個參數的range: ")
  14. list3 = range(1,10,2)
  15. print(list3[4])
複製代碼

TOP

  1. list1=range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. list2=(3,8)
  6. print("參數的range: ")
  7. print(list2[0])
  8. print(list2[4])
  9. print("三個參數的range: ")
  10. list3=(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])
  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. #0~9 陣列 只丟一個參數的時候
  2. list1 = range(10)
  3. print("一個參數的range: ")
  4. print(list1[0])
  5. print(list1[9])
  6. #3~7 range(起始值,終止值)
  7. lisr2 = range(3,8)
  8. print("兩個參數的range: ")
  9. print(lisr2[0])
  10. print(lisr2[4])

  11. #range(起始值,終止值, 間隔值)
  12. #1 3 5 7 9
  13. print("三個參數的range: ")
  14. list3 = range(1,10,2)
  15. print(list3[4])
複製代碼

TOP

  1. #0~9 陣列 只丟一個參數的時候
  2. list1=range(10)
  3. print("一個參數的range: ")
  4. print(list1[0])
  5. print(list1[9])
  6. #3~7 range(起始值,終止值)
  7. list2=range(3,8)
  8. print("兩個參數的range: ")
  9. print(list2[0])   
  10. print(list2[4])
  11.    
  12. #range(起始值,終止值, 間隔值)
  13. #1 3 5 7 9
  14. print("三個參數的range: ")
  15. list3=range(1,10,2)
  16. print(list3[4])
複製代碼

TOP

  1. print("1個參數的range:")
  2. list1=range(10)
  3. print(list1[4])
  4. print(list1[8])
  5. list2=range(3,8)
  6. print("2個參數的range:")
  7. print(list2[1])
  8. print(list2[4])


  9. print("3個參數的range:")
  10. list3 = range(1,10,3)#
  11. print(list3[2])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])
  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])

  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])

  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. list1 = range(9)
  2. print(list1[0])
  3. print(list1[8])

  4. list2 = range(4,9)
  5. print(list2[0])
  6. print(list2[4])

  7. list3 = range(1,10,2)
  8. print(list3[4])
  9. print(list3[2])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])
  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. list1 = range(10)
  2. print("一個參數的range: ")
  3. print(list1[0])
  4. print(list1[9])
  5. lisr2 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr2[0])
  8. print(lisr2[4])
  9. print("三個參數的range: ")
  10. list3 = range(1,10,2)
  11. print(list3[4])
複製代碼

TOP

  1. a=range(6)
  2. b=range(2, 15)
  3. c=range(5, 101,5)
  4. print(a[5])
  5. print(b[12])
  6. print(c[19])
複製代碼

TOP

  1. list12 = range(10)
  2. print("一個參數的range: ")
  3. print(list12[0])
  4. print(list12[9])
  5. lisr23 = range(3,8)
  6. print("兩個參數的range: ")
  7. print(lisr23[0])
  8. print(lisr23[4])
  9. print("三個參數的range: ")
  10. list34 = range(1,10,2)
  11. print(list34[4])
複製代碼
陳頡鴻

TOP

返回列表