Page 191 - Robotics and AI class 10
P. 191

Datatype of        ARR.dtype          import numpy as np                  int64
              elements stored in                    ARR =
              the array                             np.array([[1,2,3,4],

                                                    [3,4,5,6]])
                                                    print(ARR.dtype)
              Maximum value in  ARR.max()           import numpy as np                  45
              the element of the                    ARR =
              array                                 np.array([[10,34,45,

                                                    23,12]])
                                                    print(ARR.max())

              Row wise &         ARR.max(axis=1)    import numpy as np                  Rowwise max : [13  6]
              column wise        for row            ARR =                               Column wise max : [11

              maximum value      ARR.max(axis=0)  np.array([[11,2,13,4],                4 13  6]
                                 for column         [3,4,5,6]])
                                                    print("Rowwise max :",

                                                    ARR.max(axis=1))
                                                    print("Column wise max :",
                                                    ARR.max(axis=0))

              Row wise &         ARR.min(axis=1)  import numpy as np                    Rowwise min : [2 3]
              column wise        for row            ARR =                               Column wise min : [3
              minimum value      ARR.min(axis=0)  np.array([[11,2,13,4],                2 5 4]
                                 for column         [3,4,5,6]])
                                                    print("Rowwise min :",
                                                    ARR.min(axis=1))
                                                    print("Column wise min :",
                                                    ARR.min(axis=0))


              Sum of all values   ARR.sum()         import numpy as np                  Rowwise sum : [30 18]
              in the given array                    ARR =                               Column wise sum : [14

                                                    np.array([[11,2,13,4],              6 18 10]
                                                    [3,4,5,6]])                         sum is : 48
                                                    print("Row Wise sum :",
                                                    ARR.sum(axis=1))
                                                    print("Column wise sum :",
                                                    ARR.sum(axis=0))
                                                    print("sum is :",
                                                    ARR.sum())








                                                         Introduction to Data and Programming with Python  189
   186   187   188   189   190   191   192   193   194   195   196