From 7c12ce511ddd9105cad27a863b541f4edbcffe49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CMSS3-ALSULAIMA=E2=80=9D?= <Mohammed3.Alsulaimani@live.uwe.ac.uk> Date: Wed, 8 Nov 2023 16:28:07 +0400 Subject: [PATCH] std_value --- UFCFVQ-15-M Programming Task 1 Template.ipynb | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/UFCFVQ-15-M Programming Task 1 Template.ipynb b/UFCFVQ-15-M Programming Task 1 Template.ipynb index abd1451..867e06c 100644 --- a/UFCFVQ-15-M Programming Task 1 Template.ipynb +++ b/UFCFVQ-15-M Programming Task 1 Template.ipynb @@ -70,10 +70,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The standard deviation is: 8.65544144839919\n" + ] + } + ], + "source": [ + "def find_std(numbers, mean):\n", + "\n", + "# Find the variance by averaging the squared differences, from the mean.\n", + "# Then take the root to obtain the standard deviation.\n", + "\n", + " std_value = (sum([(x - mean) ** 2 for x in numbers]) / len(numbers)) ** 0.5\n", + " return (std_value)\n", + "\n", + "# Determine the mean of the numbers_list using the function we defined earlier.\n", + "\n", + "mean_value = arithmetic_mean(numbers_list)\n", + "\n", + "# Calculate the deviation using the find_std function and the mean_value.\n", + "\n", + "std_value = find_std(numbers_list, mean_value)\n", + "\n", + "# Print the calculated standard deviation\n", + "\n", + "print(f\"The standard deviation is: {std_value}\")\n" + ] }, { "cell_type": "markdown", -- GitLab