Working with NumPy Library
In this step, we will introduce the NumPy library for numerical computing. We will work on arrays, perform basic operations, and calculate statistical values.
Now, let's add code to /home/labex/project/numpy_operations.py
for performing basic numerical computations using the NumPy library.
## numpy_operations.py
## Working with NumPy Library
import numpy as np
## Creating arrays
array1 = np.array([1, 2, 3, 4, 5])
array2 = np.array([6, 7, 8, 9, 10])
## Performing array operations
result_addition = array1 + array2
print("Result of addition:", result_addition)
## Calculating mean
mean_value = np.mean(array1)
print("Mean value of array1:", mean_value)
Run the script:
python numpy_operations.py
The information below should be displayed on your terminal:
Result of addition: [ 7 9 11 13 15]
Mean value of array1: 3.0