Python range()
'''
range() is a built-in function
return: a list of integers
it could be used like this:
range(stop)
range(start, stop)
range(start, stop, step)
in terminal:
python
help(range)
q
exit()
clear
'''
list = range(5)
print(list)
# [0, 1, 2, 3, 4]
#
# stop is excluded
# default start is 0
# default step is 1
# default start is 0
# default step is 1
# stop is excluded
# start and stop should not be ==
list = range(0)
print(list)
# []
# stop should not be == start
list = range(1, 1)
print(list)
# []
# default start is 0
# default step is 1
# stop should not be smaller than start
list = range(-1)
print list
# []
# stop should not be smaller than start
list = range(5, 3)
print list
# []
# when stop IS smaller than start, step should be a negative
list = range(5, 3, -1)
print list
# [5, 4]
# same with negative
# stop should not be smaller than start
list = range(-3, -5)
print list
# []
# when stop is smaller than start, step should be a negative
list = range(-3, -5, -1)
print list
# [-3, -4]
list = range(-5, -3)
print list
# [-5, -4]
相關文章
- python-rangePython
- Python range() 函式用法Python函式
- python入門:range函式Python函式
- Python錯題本(1)range()Python
- python range()函式指定數值Python函式
- Python3 range() 函式用法Python函式
- python開發的range()函式Python函式
- golang for range 遍歷 對比 PHP、pythonGolangPHPPython
- PyThon range()函式中for迴圈用法Python函式
- Python中range和xrange的區別Python
- Python range與enumerate函式區別解析Python函式
- Python range()函式有什麼作用?如何使用?Python函式
- python爬蟲 -IndexError: list index out of range報錯Python爬蟲IndexError
- 技術原理:Python中range和xrange對比Python
- range方法在Python2和Python3中的不同Python
- Python學習系列之 xrange和range的區別!Python
- Python:range、np.arange和np.linspacePython
- HTML input rangeHTML
- Range Sparse Net
- Python錯誤集錦:for x in range(5) ^ SyntaxError: invalid syntaxPythonError
- Convert Range-Partitioned Table To Interval-Range-Partitioned Table
- Python中的arange是什麼?和range有什麼不同?Python
- Python中列表遍歷使用range和enumerate的區別Python
- 輕鬆初探 Python 篇(四)—list tuple range 知識彙總Python
- Golang for range的坑Golang
- MySQL RANGE分割槽MySql
- golang range的用法Golang
- MySQL range問題MySql
- Global Range Partitioned IndexesIndex
- B. Range and Partition
- Range Minimum Sum
- http斷點續傳原理:http頭 Range、Content-RangeHTTP斷點
- Go-For Range 效能研究Go
- The Range of Application2APP
- GO 的 range 如何使用?Go
- Leetcode Search for a RangeLeetCode
- Index Range Scan (214)Index
- ABAP Range 選擇表