python sequence of numbers code example
Example 1: for i in range start
for i in range([start], stop[, step])
Example 2: python range in intervals of 10
print("using start, stop, and step arguments in Python range() function")
print("Printing All odd numbers between 1 and 10 using range()")
for i in range(1, 10, 2):
print(i, end=', ')
Example 3: sequence with numbers in python
step = 2
vec = [1,2,3,4,5]
vec2 = [i/step for i in range(len(vec))]
# vec2 = [0.5, 1, 1.5, 2, 2.5]
Example 4: range python start at 1
>>> def range1(start, end):
... return range(start, end+1)
...
>>> range1(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]