From 28d6c597fdaa888d4b0852d5e90a411a82b633d5 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Sun, 12 May 2024 00:14:42 +0530 Subject: [PATCH 01/12] Updated List of sections --- contrib/numpy/index.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 82596a2f..bba14f22 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,3 +1,14 @@ # List of sections +* [NumPy](#NumPy) + * [Introduction to Numpy](#introduction-to-numpy) + * [Creating Arrays](#creating-arrays) + * [Array Indexing and Slicing](#arrays-indexing-and-slicing) + * [Operations on Arrays](#operation-on-arrays) + * [Concatenating Arrays](#concatenating-arrays) + * [Reshaping Arrays](#reshaping-arrays) + * [Splitting Arrays](#splitting-arrays) + * [Statistical Operations on Arrays](#statistical-operations-on-arrays) + * [Loading Arrays from Files](#loading-arrays-from-files) + * [Saving NumPy Arrays in Files](#saving-numpy-arrays-in-files) -- [Section title](filename.md) +- [Introduction to Numpy](introduction-to-numpy.md) From 0bb3e5f4f2c1a51529275b7ce0e0d756e2dbc87c Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Sun, 12 May 2024 01:56:28 +0530 Subject: [PATCH 02/12] Updated index.md Added info about how to install NumPy in a system. --- contrib/numpy/index.md | 97 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 83 insertions(+), 14 deletions(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index bba14f22..98cf425a 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,14 +1,83 @@ -# List of sections -* [NumPy](#NumPy) - * [Introduction to Numpy](#introduction-to-numpy) - * [Creating Arrays](#creating-arrays) - * [Array Indexing and Slicing](#arrays-indexing-and-slicing) - * [Operations on Arrays](#operation-on-arrays) - * [Concatenating Arrays](#concatenating-arrays) - * [Reshaping Arrays](#reshaping-arrays) - * [Splitting Arrays](#splitting-arrays) - * [Statistical Operations on Arrays](#statistical-operations-on-arrays) - * [Loading Arrays from Files](#loading-arrays-from-files) - * [Saving NumPy Arrays in Files](#saving-numpy-arrays-in-files) - -- [Introduction to Numpy](introduction-to-numpy.md) +# Installing NumPy + +- [Installing NumPy](installing-numpy.md) + +NumPy is the fundamental package for scientific computing in Python. +NumPy is used for working with arrays. + +The only prerequisite for installing NumPy is Python itself. +# +**Step 1: Check if PIP is Installed** + +Before installing NumPy, it's essential to ensure that PIP (Python Package Installer) is installed on your system. PIP is a package management system used to install and manage Python packages. You can verify if PIP is installed by running a simple command in your terminal or command prompt. + +``` +pip --version +``` + +If PIP is not currently installed on your system, you can install it by visiting the [pypi.org](https://pypi.org/project/pip/) webpage. + +# +**Step 2: Installing PIP** + +**get-pip.py** + +This is a Python script that uses some bootstrapping logic to install pip. + +Open a terminal / command prompt and run: + +**Linux** +``` +python get-pip.py +``` + +**Windows** +``` +py get-pip.py +``` + +**MacOS** +``` +python get-pip.py +``` + +# +**Step 3: Installing NumPy** + +NumPy can be installed either through conda or pip. + +If you use pip, you can install NumPy with: + +``` +pip install numpy +``` + +If you use conda, you can install NumPy from the defaults or conda-forge channels: + +``` +# Best practice, use an environment rather than install in the base env +conda create -n my-env +conda activate my-env +``` + +``` +# If you want to install from conda-forge +conda config --env --add channels conda-forge +``` + +``` +# The actual install command +conda install numpy +``` + +You can find more information about how to install [NumPy](https://numpy.org/install/) on numpy.org. + +# +**Step 4: Check if NumPy is Installed** + +We can utilize the "pip show" command not only to display the version but also to determine whether NumPy is installed on the system. +``` +pip show numpy +``` + + From 111553aee7bc4a6f81f5cfec6d0b34ad513601f2 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 13 May 2024 06:47:29 +0530 Subject: [PATCH 03/12] Added installing numpy.md file and updated the index.md --- contrib/numpy/index.md | 82 +----------------------------------------- 1 file changed, 1 insertion(+), 81 deletions(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 98cf425a..cf992512 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,83 +1,3 @@ # Installing NumPy -- [Installing NumPy](installing-numpy.md) - -NumPy is the fundamental package for scientific computing in Python. -NumPy is used for working with arrays. - -The only prerequisite for installing NumPy is Python itself. -# -**Step 1: Check if PIP is Installed** - -Before installing NumPy, it's essential to ensure that PIP (Python Package Installer) is installed on your system. PIP is a package management system used to install and manage Python packages. You can verify if PIP is installed by running a simple command in your terminal or command prompt. - -``` -pip --version -``` - -If PIP is not currently installed on your system, you can install it by visiting the [pypi.org](https://pypi.org/project/pip/) webpage. - -# -**Step 2: Installing PIP** - -**get-pip.py** - -This is a Python script that uses some bootstrapping logic to install pip. - -Open a terminal / command prompt and run: - -**Linux** -``` -python get-pip.py -``` - -**Windows** -``` -py get-pip.py -``` - -**MacOS** -``` -python get-pip.py -``` - -# -**Step 3: Installing NumPy** - -NumPy can be installed either through conda or pip. - -If you use pip, you can install NumPy with: - -``` -pip install numpy -``` - -If you use conda, you can install NumPy from the defaults or conda-forge channels: - -``` -# Best practice, use an environment rather than install in the base env -conda create -n my-env -conda activate my-env -``` - -``` -# If you want to install from conda-forge -conda config --env --add channels conda-forge -``` - -``` -# The actual install command -conda install numpy -``` - -You can find more information about how to install [NumPy](https://numpy.org/install/) on numpy.org. - -# -**Step 4: Check if NumPy is Installed** - -We can utilize the "pip show" command not only to display the version but also to determine whether NumPy is installed on the system. -``` -pip show numpy -``` - - +- [Installing NumPy](installing numpy.md) From f549e34b5dd6aafb5f070121e7ada90edadfa911 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 13 May 2024 06:49:07 +0530 Subject: [PATCH 04/12] Added installing-numpy.md file and updated the index.md --- contrib/numpy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index cf992512..6377e236 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,3 +1,3 @@ # Installing NumPy -- [Installing NumPy](installing numpy.md) +- [Installing NumPy](installing-numpy.md) From 705e55e3e7f5d58458acded41586d3e8e283e7cc Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Mon, 13 May 2024 06:53:33 +0530 Subject: [PATCH 05/12] Create installing-numpy.md for installation --- contrib/numpy/installing-numpy.md | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 contrib/numpy/installing-numpy.md diff --git a/contrib/numpy/installing-numpy.md b/contrib/numpy/installing-numpy.md new file mode 100644 index 00000000..c9fae64a --- /dev/null +++ b/contrib/numpy/installing-numpy.md @@ -0,0 +1,79 @@ +# Installing NumPy + +NumPy is the fundamental package for scientific computing in Python. +NumPy is used for working with arrays. + +The only prerequisite for installing NumPy is Python itself. +# +**Step 1: Check if PIP is Installed** + +Before installing NumPy, it's essential to ensure that PIP (Python Package Installer) is installed on your system. PIP is a package management system used to install and manage Python packages. You can verify if PIP is installed by running a simple command in your terminal or command prompt. + +``` +pip --version +``` + +If PIP is not currently installed on your system, you can install it by visiting the [pypi.org](https://pypi.org/project/pip/) webpage. + +# +**Step 2: Installing PIP** + +**get-pip.py** + +This is a Python script that uses some bootstrapping logic to install pip. + +Open a terminal / command prompt and run: + +**Linux** +``` +python get-pip.py +``` + +**Windows** +``` +py get-pip.py +``` + +**MacOS** +``` +python get-pip.py +``` + +# +**Step 3: Installing NumPy** + +NumPy can be installed either through conda or pip. + +If you use pip, you can install NumPy with: + +``` +pip install numpy +``` + +If you use conda, you can install NumPy from the defaults or conda-forge channels: + +``` +# Best practice, use an environment rather than install in the base env +conda create -n my-env +conda activate my-env +``` + +``` +# If you want to install from conda-forge +conda config --env --add channels conda-forge +``` + +``` +# The actual install command +conda install numpy +``` + +You can find more information about how to install [NumPy](https://numpy.org/install/) on numpy.org. + +# +**Step 4: Check if NumPy is Installed** + +We can utilize the "pip show" command not only to display the version but also to determine whether NumPy is installed on the system. +``` +pip show numpy +``` From 18c9837a1d74fe6de1310f9b02248f89a983fa98 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 15:09:26 +0530 Subject: [PATCH 06/12] Update index.md Added operations-on-arrays.md --- contrib/numpy/index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 6377e236..e39f4850 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,3 +1,4 @@ -# Installing NumPy +# NumPy - [Installing NumPy](installing-numpy.md) +- [Operations on Arrays in NumPy](operations-on-arrays.md) From 7c84dcee772d851af5b648ea1bc6343d21a87af3 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:04:16 +0530 Subject: [PATCH 07/12] Create operations-on-arrays.md --- contrib/numpy/operations-on-arrays.md | 246 ++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 contrib/numpy/operations-on-arrays.md diff --git a/contrib/numpy/operations-on-arrays.md b/contrib/numpy/operations-on-arrays.md new file mode 100644 index 00000000..5c2be798 --- /dev/null +++ b/contrib/numpy/operations-on-arrays.md @@ -0,0 +1,246 @@ +# Operations on Arrays + +## NumPy Arithmetic Operations + +
+ +NumPy offers a broad array of operations for arrays, including arithmetic functions. + +The arithmetic operations in NumPy are popular for their simplicity and efficiency in handling array calculations. + +Here is a list of different arithmetic operations along with their corresponding operators: + +| Element-wise Operation | Operator | +|------------------------|:--------:| +| Addition | + | +| Subtraction | - | +| Multiplication | * | +| Division | / | +| Exponentiation | ** | +| Modulus | % | + +# + +### Code Initialization + +```python +import numpy as np + +array_1 = np.array([9, 10, 11, 12]) +array_2 = np.array([1, 3, 5, 7]) +``` + +### Addition +```python +# Utilizing the + operator +result_1 = array_1 + array_2 +print("Utilizing the + operator:", result_1) +``` + +Output: +``` +Utilizing the + operator: [10 13 16 19] +``` + +### Subtraction +```python +# Utilizing the - operator +result_1 = array_1 - array_2 +print("Utilizing the - operator:", result_1) +``` + +Output: +``` +Utilizing the - operator: [8 7 6 5] +``` + +### Multiplication +```python +# Utilizing the * operator +result_1 = array_1 * array_2 +print("Utilizing the * operator:", result_1) +``` + +Output: +``` +Utilizing the * operator: [9 30 55 84] +``` + +### Division +```python +# Utilizing the / operator +result_1 = array_1 / array_2 +print("Utilizing the / operator:", result_1) +``` + +Output: +``` +Utilizing the / operator: [9. 3.33333333 2.2 1.71428571] +``` + +### Exponentiation +```python +# Utilizing the ** operator +result_1 = array_1 ** array_2 +print("Utilizing the ** operator:", result_1) +``` + +Output: +``` +Utilizing the ** operator: [9 1000 161051 35831808] +``` + +### Modulus +```python +# Utilizing the % operator +result_1 = array_1 % array_2 +print("Utilizing the % operator:", result_1) +``` + +Output: +``` +Utilizing the ** operator: [0 1 1 5] +``` + +
+ +## NumPy Comparision Operations + +
+ +NumPy provides various comparison operators that can compare elements across multiple NumPy arrays. + +| Operator | Description | +|:--------:|-------------------------------------------------------------------------------------------------------------------------------| +| < | Evaluates to True if the element in the first array is less than the corresponding element in the second array | +| <= | Evaluates to True if the element in the first array is less than or equal to the corresponding element in the second array | +| > | Evaluates to True if the element in the first array is greater than the corresponding element in the second array | +| >= | Evaluates to True if the element in the first array is greater than or equal to the corresponding element in the second array | +| == | Evaluates to True if the element in the first array is equal to the corresponding element in the second array | +| != | Evaluates to True if the element in the first array is not equal to the corresponding element in the second array | + +# + +### Code Initialization + +```python +import numpy as np + +array_1 = np.array([12,15,20]) +array_2 = np.array([20,15,12]) +``` + +#### less than operator +```python +result_1 = array_1 < array_2 +print("array_1 < array_2:",result_1) +``` +Output: +``` +array_1 < array_2 : [True False False] +``` + +#### less than or equal to operator +```python +result_1 = array_1 <= array_2 +print("array_1 <= array_2:",result_1) +``` +Output: +``` +array_1 <= array_2: [True True False] +``` + +#### greater than operator +```python +result_2 = array_1 > array_2 +print("array_1 > array_2:",result_2) +``` +Output: +``` +array_1 > array_2 : [False False True] +``` + +#### greater than or equal to operator +```python +result_2 = array_1 >= array_2 +print("array_1 >= array_2:",result_2) +``` +Output: +``` +array_1 >= array_2: [False True True] +``` + +#### equal to operator +```python +result_3 = array_1 == array_2 +print("array_1 == array_2:",result_3) +``` +Output: +``` +array_1 == array_2: [False True False] +``` + +#### not equal to operator +```python +result_3 = array_1 != array_2 +print("array_1 != array_2:",result_3) +``` +Output: +``` +array_1 != array_2: [True False True] +``` + +
+ +## NumPy Logical Operations + +
+ +Logical operators perform Boolean algebra. A branch of algebra that deals with True and False statements. + +| Operator | Description | +|---------------|-----------------------------------------------------| +| logical_and | Evaluates the element-wise truth value of x1 AND x2 | +| logical_or | Evaluates the element-wise truth value of x1 OR x2 | +| logical_not | Evaluates the element-wise truth value of NOT x | + + +It illustrates the logical operations of AND, OR, and NOT using np.logical_and(), np.logical_or(), and np.logical_not() functions, respectively. + +# + +### Code Initialization + +```python +import numpy as np + +array_1 = np.array([True, False, True]) +array_2 = np.array([False, False, True]) +``` + +#### Logical AND +```python +print(np.logical_and(array_1, array_2)) +``` +Output: +``` +[False False True] +``` + +#### Logical OR +```python +print(np.logical_or(array_1, array_2)) +``` +Output: +``` +[True False True] +``` + +#### Logical NOT +```python +print(np.logical_not(array_1)) +``` +Output: +``` +[False True False] +``` From 9e9e17f51508791dde80c9826497a1a17ae3a96d Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:04:35 +0530 Subject: [PATCH 08/12] Update index.md --- contrib/numpy/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index e39f4850..757407a6 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,4 +1,4 @@ -# NumPy +# List of sections - [Installing NumPy](installing-numpy.md) - [Operations on Arrays in NumPy](operations-on-arrays.md) From 57f73ec029a64917fb6bb83a678ef075509dfeb6 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:10:46 +0530 Subject: [PATCH 09/12] Update index.md --- contrib/numpy/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/numpy/index.md b/contrib/numpy/index.md index 757407a6..18f10b20 100644 --- a/contrib/numpy/index.md +++ b/contrib/numpy/index.md @@ -1,4 +1,4 @@ # List of sections -- [Installing NumPy](installing-numpy.md) -- [Operations on Arrays in NumPy](operations-on-arrays.md) +- [Installing NumPy](installing_numpy.md) +- [Operations on Arrays in NumPy](operations_on_arrays.md) From 5a23eb9ab04c549503b39c99fef19ebb0fae770b Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:11:45 +0530 Subject: [PATCH 10/12] Rename installing-numpy.md to installing_numpy.md --- contrib/numpy/{installing-numpy.md => installing_numpy.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/numpy/{installing-numpy.md => installing_numpy.md} (100%) diff --git a/contrib/numpy/installing-numpy.md b/contrib/numpy/installing_numpy.md similarity index 100% rename from contrib/numpy/installing-numpy.md rename to contrib/numpy/installing_numpy.md From 7477daf106d0b269111b32fa634409bf16adee54 Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:12:07 +0530 Subject: [PATCH 11/12] Rename operations-on-arrays.md to operations_on_arrays.md --- .../numpy/{operations-on-arrays.md => operations_on_arrays.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/numpy/{operations-on-arrays.md => operations_on_arrays.md} (100%) diff --git a/contrib/numpy/operations-on-arrays.md b/contrib/numpy/operations_on_arrays.md similarity index 100% rename from contrib/numpy/operations-on-arrays.md rename to contrib/numpy/operations_on_arrays.md From 23acb72abe0fe19a823152d5212a143c10b6491f Mon Sep 17 00:00:00 2001 From: Yodha Sudarsi <101962069+Yodha-Sudarsi@users.noreply.github.com> Date: Wed, 15 May 2024 20:13:26 +0530 Subject: [PATCH 12/12] Update installing_numpy.md --- contrib/numpy/installing_numpy.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/numpy/installing_numpy.md b/contrib/numpy/installing_numpy.md index c9fae64a..7339e8cf 100644 --- a/contrib/numpy/installing_numpy.md +++ b/contrib/numpy/installing_numpy.md @@ -9,13 +9,14 @@ The only prerequisite for installing NumPy is Python itself. Before installing NumPy, it's essential to ensure that PIP (Python Package Installer) is installed on your system. PIP is a package management system used to install and manage Python packages. You can verify if PIP is installed by running a simple command in your terminal or command prompt. -``` +```bash pip --version ``` If PIP is not currently installed on your system, you can install it by visiting the [pypi.org](https://pypi.org/project/pip/) webpage. # + **Step 2: Installing PIP** **get-pip.py** @@ -25,28 +26,29 @@ This is a Python script that uses some bootstrapping logic to install pip. Open a terminal / command prompt and run: **Linux** -``` +```bash python get-pip.py ``` **Windows** -``` +```bash py get-pip.py ``` **MacOS** -``` +```bash python get-pip.py ``` # + **Step 3: Installing NumPy** NumPy can be installed either through conda or pip. If you use pip, you can install NumPy with: -``` +```bash pip install numpy ``` @@ -71,9 +73,10 @@ conda install numpy You can find more information about how to install [NumPy](https://numpy.org/install/) on numpy.org. # + **Step 4: Check if NumPy is Installed** We can utilize the "pip show" command not only to display the version but also to determine whether NumPy is installed on the system. -``` +```bash pip show numpy ```