In [1]:
# print(xrange(3))
# NameError: name 'xrange' is not defined
In [2]:
print(range(3))
In [3]:
print(type(range(3)))
In [4]:
for i in range(3):
print(i)
In [5]:
print(list(range(3)))
In [6]:
print(list(range(10)))
In [7]:
print(list(range(-3)))
In [8]:
print(list(range(3, 10)))
In [9]:
print(list(range(10, 3)))
In [10]:
print(list(range(-3, 3)))
In [11]:
print(list(range(3, -3)))
In [12]:
print(range(0, 3) == range(3))
In [13]:
print(list(range(3, 10, 2)))
In [14]:
print(list(range(10, 3, 2)))
In [15]:
print(list(range(10, 3, -2)))
In [16]:
print(list(range(3, 10, -2)))
In [17]:
print(range(3, 10, 1) == range(3, 10))
In [18]:
print(range(0, 10, 1) == range(0, 10) == range(10))
In [19]:
print(list(range(3, 10, 2)))
In [20]:
print(list(range(9, 2, -2)))
In [21]:
print(list(reversed(range(3, 10, 2))))
In [22]:
for i in reversed(range(3, 10, 2)):
print(i)
In [23]:
# print(list(range(0.3, 1.0, 0.2)))
# TypeError: 'float' object cannot be interpreted as an integer
In [24]:
print([i / 10 for i in range(3, 10, 2)])
In [25]:
print([i * 0.1 for i in range(3, 10, 2)])
In [26]:
print([round(i * 0.1, 1) for i in range(3, 10, 2)])