# ranges[Sequential invariant sequence of numbers]
DefRanges ():
#Create
Ranges =Range10)
ls =List (ranges)# <class ' list ';: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Ranges =Range1,10)
ls =List (ranges)# <class ' list ';: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Ranges =Range1, -10, -2)# (Begin,Stop it,Steps)
ls =List (ranges)# <class ' list ';: [1,-1,-3,-5,-7,-9]
#Get
Ranges =Range10)
num = Ranges.index (5)# 5
num = ranges[5]# 5
R1 = ranges[:5]# Range (0, 5)
ls =List (R1)# <class ' list ';: [0, 1, 2, 3, 4]
r2 = ranges[1:5]# Range (1, 5)
ls =List (R2)# <class ' list ';: [1, 2, 3, 4]
R3 = ranges[1:5:2]# Range (1, 5, 2)
ls =List (R3)# <class ' list ';: [1, 3]
# Judge
boolean = 5 in ranges
boolean = Span style= "COLOR: #6897bb" >5 not in Ranges
# advanced usage
L4 = list (X**2 for x in" Span style= "COLOR: #8888c6" >range (15) # so faster < Class ' list ': [1, 4, 9, +]
Range (if xRange (if y%2 = =
# <class ' list ';: [1, 3, 5, 7, 9, 3, 5, 7, 9, 11, 5, 7, 9, 11, 13]
python3-notes-b-004-data structure-range