/ Python And R Data science skills: 38 Numpy Qustions and answers in telugu

Sunday 4 February 2018

38 Numpy Qustions and answers in telugu

38 Numpy Exercise telugu part 01
In [1]:
import numpy as np
In [2]:
np.zeros(10)
Out[2]:
array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])
In [4]:
np.arange(10)*0
Out[4]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
In [5]:
np.ones(10)
Out[5]:
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])
In [6]:
np.ones(10)*5
Out[6]:
array([ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.])
In [7]:
np.zeros(10)+5
Out[7]:
array([ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.])
In [8]:
np.arange(10,51)
Out[8]:
array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
       27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
       44, 45, 46, 47, 48, 49, 50])
In [9]:
np.arange(10,51).shape
Out[9]:
(41,)
In [10]:
np.arange(10,51,2).r
Out[10]:
array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,
       44, 46, 48, 50])
In [12]:
a=np.arange(0,9)
In [13]:
a.reshape(3,3)
Out[13]:
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
In [14]:
np.arange(0,9).reshape(3,3)
Out[14]:
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])
In [15]:
np.eye(3)
Out[15]:
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
In [16]:
np.eye(4)
Out[16]:
array([[ 1.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  0.],
       [ 0.,  0.,  0.,  1.]])
In [22]:
np.random.rand()
Out[22]:
0.7090648141240633
In [24]:
np.random.randn(25).shape
Out[24]:
(25,)
In [26]:
np.random.randn(25)
Out[26]:
array([ 0.55678286, -0.18580945,  0.08005477,  0.53654464,  0.4838399 ,
        1.09138556,  1.00688417,  0.39684701, -1.23368431,  1.9531891 ,
       -1.10672488, -0.13322277, -1.31102628,  1.15314581, -0.30520792,
        0.07456077,  0.74786091, -0.19769166,  0.51588943, -1.11648334,
       -0.13272016, -0.19173315, -0.90512719,  0.0816647 ,  1.2630266 ])

No comments:

Post a Comment