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.arange(5)
Out[3]:
array([0, 1, 2, 3, 4])
In [4]:
np.zeros(5)
Out[4]:
array([0., 0., 0., 0., 0.])
In [6]:
np.zeros([5,5])
Out[6]:
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 [7]:
np.ones(5)
Out[7]:
array([1., 1., 1., 1., 1.])
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 [15]:
sum(a)
Out[15]:
6
In [17]:
np.std(a)
Out[17]:
0.816496580927726
In [18]:
np.average(a)
Out[18]:
2.0
In [20]:
arr = np.arange(25)
In [26]:
arr = arr.reshape([5,5])
In [29]:
arr
Out[29]:
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 [30]:
arr[2:5,2:5]
Out[30]:
array([[12, 13, 14],
       [17, 18, 19],
       [22, 23, 24]])
In [33]:
arr[1:3, 1:3]
Out[33]:
array([[ 6,  7],
       [11, 12]])
In [35]:
np.random.rand(2,2)
Out[35]:
array([[0.87573525, 0.89183523],
       [0.80687252, 0.21062591]])
In [36]:
np.random.randn(2,2)
Out[36]:
array([[ 0.15245335, -1.30313843],
       [ 1.71233505,  1.0160887 ]])
In [37]:
np.random.randint(1,10,[2,2])
Out[37]:
array([[6, 7],
       [6, 6]])
In [41]:
a = [1,2,3]
In [39]:
(1,2,3)
Out[39]:
(1, 2, 3)
In [40]:
{1,2,3}
Out[40]:
{1, 2, 3}
In [42]:
a
Out[42]:
[1, 2, 3]
In [43]:
a[0] = 9
In [44]:
a
Out[44]:
[9, 2, 3]
In [45]:
b = (1,2,3)
In [46]:
b[0]
Out[46]:
1
In [47]:
b[0] = 9
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-47-f6a8611d795c> in <module> ----> 1 b[0] = 9 TypeError: 'tuple' object does not support item assignment
In [48]:
{1,1,2,3,2,1,2,3,2,1,2}
Out[48]:
{1, 2, 3}
In [49]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: