In [1]:
L = list(range(10))
In [2]:
L
Out[2]:
In [3]:
type(L)
Out[3]:
In [4]:
type(L[0])
Out[4]:
In [5]:
L2 = [str(c) for c in L]
type(L2[0])
Out[5]:
In [6]:
all(type(e) == int for e in L)
Out[6]:
In [7]:
L3 = [True, '2', 3.0, 4]
[type(item) for item in L3]
Out[7]:
In [8]:
tuple(L3)
Out[8]:
In [9]:
import numpy as np
np.array([1, 4, 2, 5, 3])
Out[9]:
In [10]:
np.array([3.14, 4, 2, 3])
Out[10]:
In [11]:
# create a random integer array
np.random.randint(0, 10, (3, 3))
Out[11]:
In [12]:
# create a 3x3 array of uniform random values
np.random.random((3, 3))
Out[12]:
In [13]:
# create 3x3 array of normally distributed data
np.random.normal(0, 1, (3,3))
Out[13]:
In [ ]: