diff --git a/_sources/index_en.rst b/_sources/index_en.rst index 07582b56c2..83d672e946 100644 --- a/_sources/index_en.rst +++ b/_sources/index_en.rst @@ -54,6 +54,6 @@ Contents: challenges/Reto03_en.rst challenges/Reto04_en.rst challenges/Reto05_en.rst - + poc/numpy.rst diff --git a/_sources/poc/numpy.rst b/_sources/poc/numpy.rst new file mode 100644 index 0000000000..4634e63e73 --- /dev/null +++ b/_sources/poc/numpy.rst @@ -0,0 +1,167 @@ +============== +Numpy Exercise +============== + +Introduction to Numpy +--------------------- +NumPy is a Python library that provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays efficiently. +It is widely used in scientific computing, data analysis, and machine learning due to its powerful array manipulation capabilities and efficient numerical operations. + +Numpy functions +--------------- +1. Mean ``(np.mean())`` : Calculates the arithmetic mean (average) of elements along a specified axis in an array. It computes the sum of all elements and divides it by the number of elements. +2. Median ``(np.median())``: Computes the median, which is the middle value of a sorted array. If the array has an odd number of elements, the median is the middle value. If it has an even number, it's the average of the two middle values. +3. Standard Deviation ``(np.std())``: Calculates the standard deviation, which measures the spread of data around the mean. It's the square root of the variance, where variance is the average of the squared differences from the mean. +4. Sort ``(np.sort())``: Sorts the elements of an array along a specified axis. By default, it sorts the array in ascending order along the last axis. You can specify the axis along which to sort and whether to return a sorted copy or sort the array in place. + +See the code below to understand how these functions work. + +.. raw:: html + +
+ + + + + + + NumPy Quiz + + + + + packages = ["numpy"] + terminal = false + +
+

Match the NumPy function with its description:

+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
  8. +
+ +
+ +
+ +

Try numpy functions in the Python REPL below:

+ +
+ + import numpy as np + + # Create a NumPy array + arr = np.array([1, 2, 3, 4, 5]) + + # Calculate mean + mean = np.mean(arr) + print("Mean of the array:", mean) + + # Calculate median + median = np.median(arr) + print("Median of the array:", median) + + # Sort the array + sorted_arr = np.sort(arr) + print("Sorted array:", sorted_arr) + + # Calculate standard deviation + std_dev = np.std(arr) + print("Standard deviation of the array:", std_dev) + +
+ + + + + +Instructions +------------ +``SHIFT + ENTER`` on the code cell below to see the quiz. Match the NumPy functions with their descriptions and click on the "Submit" button to check your answers. +