Jovian
⭐️
Sign In
In [1]:
import numpy as np
In [2]:
np.eye(5)
Out[2]:
array([[1., 0., 0., 0., 0.],
       [0., 1., 0., 0., 0.],
       [0., 0., 1., 0., 0.],
       [0., 0., 0., 1., 0.],
       [0., 0., 0., 0., 1.]])
In [3]:
np.ones(5)
Out[3]:
array([1., 1., 1., 1., 1.])
In [4]:
np.arange(5)
Out[4]:
array([0, 1, 2, 3, 4])
In [6]:
np.zeros(5)
Out[6]:
array([0., 0., 0., 0., 0.])
In [8]:
np.zeros([5,5])
Out[8]:
array([[0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0.],
       [0., 0., 0., 0., 0.]])
In [9]:
np.ones([3,3])
Out[9]:
array([[1., 1., 1.],
       [1., 1., 1.],
       [1., 1., 1.]])
In [10]:
len(np.ones(5))
Out[10]:
5
In [11]:
a = [1,2,3,4]
In [12]:
a.pop()
Out[12]:
4
In [13]:
a
Out[13]:
[1, 2, 3]
In [14]:
sum(a)
Out[14]:
6
In [15]:
np.std(a)
Out[15]:
0.816496580927726
In [16]:
np.average(a)
Out[16]:
2.0
In [17]:
arr = np.arange(25)
In [19]:
arr = arr.reshape([5,5])
In [20]:
arr
Out[20]:
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])
In [21]:
arr[1:3,1:3]
Out[21]:
array([[ 6,  7],
       [11, 12]])
In [24]:
arr[2:5,2:5]
Out[24]:
array([[12, 13, 14],
       [17, 18, 19],
       [22, 23, 24]])
arr[1:4,1:4]
In [25]:
arr
Out[25]:
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])
In [26]:
arr[1:3,1:3]
Out[26]:
array([[ 6,  7],
       [11, 12]])
In [27]:
np.random.rand(2,2)
Out[27]:
array([[0.89747247, 0.71904392],
       [0.59685487, 0.7071278 ]])
In [28]:
np.random.randn(2,2)
Out[28]:
array([[ 1.07174208,  0.06389602],
       [ 0.47431759, -1.87344768]])
In [29]:
np.random.randint(1,10,[2,2])
Out[29]:
array([[2, 5],
       [8, 1]])
In [30]:
#list
[1,2,3]
Out[30]:
[1, 2, 3]
In [31]:
#tuple
(1,2,3)
Out[31]:
(1, 2, 3)
In [32]:
#set
{1,2,3}
Out[32]:
{1, 2, 3}
In [33]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: