Page 226 - AI Ver 1.0 Class 10
P. 226

• Creating 1 D array with 4 random values:

                   import numpy as np
                   a = np.random.random(4)

                   print(a)
                   Output will be:
                   [0.9290503 0.89991053 0.7563874 0.89570953]

                 • Creating a 3X4 array with random integer values less than 10:

                   import numpy as np
                   a = np.random.randint(10, size=(3,4))
                   print(a)
                   Output will be:

                   [ [3 1 4 1]

                     [7 6 0 1]
                     [4 2 2 9] ]

                 • Creating two-dimensional array of 3 rows and 4 columns with all ones as value:

                   import numpy as np
                   a = np.ones((3,4))

                   print(a)
                   Output will be:
                   [ [1. 1. 1. 1.]

                     [1. 1. 1. 1.]

                     [1. 1. 1. 1.] ]
                 • Creating two-dimensional array of 3 rows and 3 columns with all zeroes as value:

                   import numpy as np
                   a = np.zeros((3,3))

                   print(a)
                   Output will be:

                   [ [0. 0. 0.]
                     [0. 0. 0.]

                     [0. 0. 0.] ]
                 • Creating two-dimensional array of 3 rows and 4 columns with all six as value:

                   import numpy as np

                   a = np.full((3,4),6)
                   print(a)




                        224   Touchpad Artificial Intelligence-X
   221   222   223   224   225   226   227   228   229   230   231