Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 160 - 2615_KEC
P. 160

    Program.py
                       File  Edit  Format    Run   Options   Window    Help

                       import numpy as np
                       matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
                       print(matrix[0:2, 1:3])

                          Output

                       [[2 3]
                         [5 6]]

                           REVISIT

                        ▶   Libraries are collections of pre-written code that extend Python's core capabilities.
                        ▶   NumPy is a powerful open-source scientific package that stands for 'Numerical Python'.
                        ▶   Arrays are an ordered  collection  of values of the same  data  type  that  can be arranged in one or more
                          dimensions.
                        ▶   Array indexing in NumPy refers to the method of accessing specific elements or subsets of data within an
                          array.
                        ▶   Indexing allows us to retrieve, modify and manipulate data at specific positions or ranges.
                        ▶   A 1D NumPy array is a sequence of values with positions called indices which starts at 0.

                      158   Premium Edition-VIII

| 155 156 157 158 159 160 161 162 163 164 165 |