diff --git a/.ipynb_checkpoints/UFCFVQ-15-M Programming Task 1 Template-checkpoint.ipynb b/.ipynb_checkpoints/UFCFVQ-15-M Programming Task 1 Template-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..9bac290815a8f8dd886b64af3dc07283d27a8e0e --- /dev/null +++ b/.ipynb_checkpoints/UFCFVQ-15-M Programming Task 1 Template-checkpoint.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# UFCFVQ-15-M Programming for Data Science\n", + "# Programming Task 1\n", + "\n", + "## Student Id: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.1 -Find the arithmetic mean using function" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The mean value is: 14.5\n" + ] + } + ], + "source": [ + "numbers_list = [\n", + " 29, 17, 28, 6, 14, 7, 4, 27, 21, 15,\n", + " 10, 16, 24, 26, 3, 11, 13, 8, 23, 9,\n", + " 0, 22, 12, 2, 18, 19, 5, 1, 20, 25\n", + "]\n", + "\n", + "# Find the average of a given list of numbers\n", + "\n", + "def arithmetic_mean(numbers):\n", + " total_sum = sum(numbers) \n", + " mean_value = total_sum / len(numbers) \n", + " return mean_value \n", + "\n", + "# Execute the function and save the resulting value\n", + "\n", + "mean_value = arithmetic_mean(numbers_list) \n", + "\n", + "# Display the average value(mean)\n", + "\n", + "print(f\"The mean value is: {mean_value}\") \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.2 - Find the standard deviation using function" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "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", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.3 - Find the min/max values using functions" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The minimum value is: 0\n", + "The maximum value is: 29\n" + ] + } + ], + "source": [ + "numbers_list = [\n", + " 29, 17, 28, 6, 14, 7, 4, 27, 21, 15,\n", + " 10, 16, 24, 26, 3, 11, 13, 8, 23, 9,\n", + " 0, 22, 12, 2, 18, 19, 5, 1, 20, 25\n", + "]\n", + "\n", + "# Create two functions that will allow you to find the min/max values, in a given list.\n", + "\n", + "def min_value(numbers):\n", + " return min(numbers)\n", + "\n", + "def max_value(numbers):\n", + " return max(numbers)\n", + "\n", + "# Find the min/max values within the list\n", + "\n", + "The_min_value = min_value(numbers_list)\n", + "The_max_value = max_value(numbers_list)\n", + "\n", + "# Display the result\n", + "\n", + "print(f\"The minimum value is: {The_min_value}\")\n", + "print(f\"The maximum value is: {The_max_value}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "\n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.4 - Find the 25th percentile using functions" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The 25th percentile is: 7\n" + ] + } + ], + "source": [ + "numbers_list = [\n", + " 29, 17, 28, 6, 14, 7, 4, 27, 21, 15,\n", + " 10, 16, 24, 26, 3, 11, 13, 8, 23, 9,\n", + " 0, 22, 12, 2, 18, 19, 5, 1, 20, 25\n", + "]\n", + "\n", + "# Function to calculate a percentile within a given list of numbers\n", + "\n", + "def calculate_percentile(numbers, percentile):\n", + " sorted_list = sorted(numbers)\n", + " index = int((len(sorted_list) - 1) * (percentile / 100.0))\n", + " return sorted_list[index]\n", + "\n", + "# Calculate the 25th percentile of the list\n", + "\n", + "percentile_25 = calculate_percentile(numbers_list, 25)\n", + "\n", + "\n", + "# Display the 25th percentile value\n", + "\n", + "print(f\"The 25th percentile is: {percentile_25}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.5 - Find the 50th percentile using functions" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The 50th percentile is: 14\n" + ] + } + ], + "source": [ + "\n", + "numbers_list = [\n", + " 29, 17, 28, 6, 14, 7, 4, 27, 21, 15,\n", + " 10, 16, 24, 26, 3, 11, 13, 8, 23, 9,\n", + " 0, 22, 12, 2, 18, 19, 5, 1, 20, 25\n", + "]\n", + "\n", + "# Function to calculate a percentile within a given list of numbers\n", + "\n", + "def calculate_percentile(numbers, percentile):\n", + " sorted_list = sorted(numbers)\n", + " index = int((len(sorted_list) - 1) * (percentile / 100.0))\n", + " return sorted_list[index]\n", + "\n", + "# Calculate the percentile_50, which is also known as the median using the function we already have.\n", + "\n", + "percentile_50 = calculate_percentile(numbers_list, 50)\n", + "print(f\"The 50th percentile is: {percentile_50}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.6 - Find the 75th percentile using functions" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# add code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.7 - Print the set of summary statistics in tabular form" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "# add code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.8 - Read data from a file into memory" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "# add code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.9 - Design and build a data structure to store CSV data in memory" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "# add code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.10 - Create a generic statistical summary function " + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "# add code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.11 Adherence to good coding standards" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Requirement FR1.12 - Process Development report" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# write here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### MARK: \n", + "#### FEEDBACK: " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.5" + }, + "vscode": { + "interpreter": { + "hash": "9ef62a9e119055cb3f7e8378d4eaf3b008dbaf8b8298b9c44f87df8240f3e8bc" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/UFCFVQ-15-M Programming Task 1 Template.ipynb b/UFCFVQ-15-M Programming Task 1 Template.ipynb index 1b3d3e4b057881268f7f752beeb44ba874081779..5dab479e1a1c73555987c7ff1fb79afae5fe30d8 100644 --- a/UFCFVQ-15-M Programming Task 1 Template.ipynb +++ b/UFCFVQ-15-M Programming Task 1 Template.ipynb @@ -277,11 +277,36 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The 75th percentile is: 21\n" + ] + } + ], "source": [ - "# add code here" + "numbers_list = [\n", + " 29, 17, 28, 6, 14, 7, 4, 27, 21, 15,\n", + " 10, 16, 24, 26, 3, 11, 13, 8, 23, 9,\n", + " 0, 22, 12, 2, 18, 19, 5, 1, 20, 25\n", + "]\n", + "\n", + "# Function to calculate a percentile within a given list of numbers\n", + "\n", + "def calculate_percentile(numbers, percentile):\n", + " sorted_list = sorted(numbers)\n", + " index = int((len(sorted_list) - 1) * (percentile / 100.0))\n", + " return sorted_list[index]\n", + "\n", + "# Calculate the percentile_75, using the function we already have.\n", + "\n", + "percentile_75 = calculate_percentile(numbers_list, 75)\n", + "\n", + "print(f\"The 75th percentile is: {percentile_75}\")\n" ] }, { @@ -442,7 +467,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.11.5" }, "vscode": { "interpreter": {