From febc915eae54bb11847b7638ebbbb14c8df757b8 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 13:33:33 +0200 Subject: [PATCH 01/14] Created using Colaboratory --- snail_and_well.ipynb | 310 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 snail_and_well.ipynb diff --git a/snail_and_well.ipynb b/snail_and_well.ipynb new file mode 100644 index 000000000..ea5242b86 --- /dev/null +++ b/snail_and_well.ipynb @@ -0,0 +1,310 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "snail-and-well.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "t3IR-fi_cuUY" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aiiwtz5qcuUf" + }, + "source": [ + "# The Snail and the Well\n", + "\n", + "A snail falls at the bottom of a 125 cm well. Each day the snail rises 30 cm. But at night, while sleeping, slides 20 cm because the walls are wet. How many days does it take for the snail to escape the well?\n", + "\n", + "**Hint**: The snail gets out of the well when it surpasses the 125cm of height.\n", + "\n", + "## Tools\n", + "\n", + "1. Loop: **while**\n", + "2. Conditional statements: **if-else**\n", + "3. Function: **print()**\n", + "\n", + "## Tasks\n", + "\n", + "#### 1. Assign the challenge data to variables with representative names: `well_height`, `daily_distance`, `nightly_distance` and `snail_position`." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "lkrJWkYPcuUh" + }, + "source": [ + "well_height = 125\n", + "daily_distance = 30\n", + "nightly_distance = 20\n", + "snail_position = 0" + ], + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "8TYYAMvkcuUj" + }, + "source": [ + "#### 2. Create a variable `days` to keep count of the days that pass until the snail escapes the well. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "pn6aSYtMcuUk" + }, + "source": [ + "days = 0" + ], + "execution_count": 12, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "DQPuRPmlcuUk" + }, + "source": [ + "#### 3. Find the solution to the challenge using the variables defined above. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "p9dWhmaLcuUl" + }, + "source": [ + "while True:\n", + " days += 1\n", + " snail_position += daily_distance\n", + " if snail_position >= well_height:\n", + " break\n", + " snail_position -= nightly_distance\n" + ], + "execution_count": 13, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "x-qxoqr1cuUm" + }, + "source": [ + "#### 4. Print the solution." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "WMNZokjocuUn", + "outputId": "713024cd-757d-4fe5-be1d-68192f927442" + }, + "source": [ + "print(days)" + ], + "execution_count": 14, + "outputs": [ + { + "output_type": "stream", + "text": [ + "11\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ST5OEgo-cuUn" + }, + "source": [ + "## Bonus\n", + "The distance traveled by the snail each day is now defined by a list.\n", + "```\n", + "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", + "```\n", + "On the first day, the snail rises 30cm but during the night it slides 20cm. On the second day, the snail rises 21cm but during the night it slides 20cm, and so on. \n", + "\n", + "#### 1. How many days does it take for the snail to escape the well?\n", + "Follow the same guidelines as in the previous challenge.\n", + "\n", + "**Hint**: Remember that the snail gets out of the well when it surpasses the 125cm of height." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "phDzTBUjcuUo", + "outputId": "3bea97f7-670d-4966-ad65-1aec80c285d5" + }, + "source": [ + "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", + "print(len(advance_cm))\n" + ], + "execution_count": 15, + "outputs": [ + { + "output_type": "stream", + "text": [ + "11\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9yDTFImycuUp" + }, + "source": [ + "#### 2. What is its maximum displacement in one day? And its minimum? Calculate the displacement using only the travel distance of the days used to get out of the well. \n", + "**Hint**: Remember that displacement means the total distance risen taking into account that the snail slides at night. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "S4WgF__ZcuUp", + "outputId": "97e9549f-0f1b-4579-de15-8e7a1f9fcd3c" + }, + "source": [ + "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", + "print(max(advance_cm))" + ], + "execution_count": 16, + "outputs": [ + { + "output_type": "stream", + "text": [ + "77\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZvcXEZZ_cuUq" + }, + "source": [ + "#### 3. What is its average progress? Take into account the snail slides at night." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TyTm03S2cuUq", + "outputId": "de082c0b-418a-43c3-df49-79d0e22be710" + }, + "source": [ + "advance_cm =[30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", + "num = sum(advance_cm)\n", + "den = len(advance_cm)\n", + "avg = num / den\n", + "print(avg)\n" + ], + "execution_count": 17, + "outputs": [ + { + "output_type": "stream", + "text": [ + "38.09090909090909\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "CP--AUP5cuUr" + }, + "source": [ + "#### 4. What is the standard deviation of its displacement? Take into account the snail slides at night." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "JeyUTfgWcuUr", + "outputId": "b69d0d7e-3ecd-4885-e05a-d88d21012694" + }, + "source": [ + "import numpy as np\n", + "advance_cm =[30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", + "print(np.std(advance_cm))" + ], + "execution_count": 18, + "outputs": [ + { + "output_type": "stream", + "text": [ + "17.159437082600803\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From 86ef1aaa2670c5e0b19b4bd5b0a5ae6dc1450ac6 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 13:55:02 +0200 Subject: [PATCH 02/14] Created using Colaboratory --- duel_of_sorcerers.ipynb | 410 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 410 insertions(+) create mode 100644 duel_of_sorcerers.ipynb diff --git a/duel_of_sorcerers.ipynb b/duel_of_sorcerers.ipynb new file mode 100644 index 000000000..54d4c949c --- /dev/null +++ b/duel_of_sorcerers.ipynb @@ -0,0 +1,410 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "duel-of-sorcerers.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "FvJVj3ZxpeQH" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "i4yCepjipeQJ" + }, + "source": [ + "# Duel of Sorcerers\n", + "You are witnessing an epic battle between two powerful sorcerers: Gandalf and Saruman. Each sorcerer has 10 spells of variable power in their mind and they are going to throw them one after the other. The winner of the duel will be the one who wins more of those clashes between spells. Spells are represented as a list of 10 integers whose value equals the power of the spell.\n", + "```\n", + "gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22]\n", + "saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]\n", + "```\n", + "For example:\n", + "- The first clash is won by Saruman: 10 against 23.\n", + "- The second clash is won by Saruman: 11 against 66.\n", + "- ...\n", + "\n", + "You will create two variables, one for each sorcerer, where the sum of clashes won will be stored. Depending on which variable is greater at the end of the duel, you will show one of the following three results on the screen:\n", + "* Gandalf wins\n", + "* Saruman wins\n", + "* Tie\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "dQva1x2bpeQK" + }, + "source": [ + "## Tools\n", + "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", + "\n", + "1. Data structures: **lists, dictionaries**\n", + "2. Loop: **for loop**\n", + "3. Conditional statements: **if-elif-else**\n", + "4. Functions: **range(), len(), print()**\n", + "\n", + "## Tasks\n", + "\n", + "#### 1. Create two variables called `gandalf` and `saruman` and assign them the spell power lists. Create a variable called `spells` to store the number of spells that the sorcerers cast. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "z5pDvW-GpeQL" + }, + "source": [ + "gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22]\n", + "saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]\n", + "spells = len(gandalf)" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZkjpXzbvpeQL" + }, + "source": [ + "#### 2. Create two variables called `gandalf_wins` and `saruman_wins`. Set both of them to 0. \n", + "You will use these variables to count the number of clashes each sorcerer wins. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Gjq-r4OnpeQL" + }, + "source": [ + "gandalf_wins = 0\n", + "saruman_wins = 0" + ], + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cxDd5RSSpeQM" + }, + "source": [ + "#### 3. Using the lists of spells of both sorcerers, update variables `gandalf_wins` and `saruman_wins` to count the number of times each sorcerer wins a clash. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "SOEIuF0npeQM" + }, + "source": [ + "for i in range(spells):\n", + " if gandalf[i] > saruman[i]:\n", + " gandalf_wins += 1\n", + " elif gandalf[i] < saruman[i]:\n", + " saruman_wins += 1" + ], + "execution_count": 5, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_jmaIx-XpeQM" + }, + "source": [ + "#### 4. Who won the battle?\n", + "Print `Gandalf wins`, `Saruman wins` or `Tie` depending on the result. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Ie202WDvpeQN", + "outputId": "478c49b7-7699-4547-996d-832effa06312" + }, + "source": [ + "if gandalf_wins > saruman_wins:\n", + " print(\"Gandalf wins\")\n", + "elif gandalf_wins < saruman_wins:\n", + " print(\"Saruman wins\")\n", + "else: \n", + " print(\"Tie\")" + ], + "execution_count": 8, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Gandalf wins\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QAPHT4KbpeQN" + }, + "source": [ + "## Bonus\n", + "\n", + "In this bonus challenge, you'll need to check the winner of the battle but this time, a sorcerer wins if he succeeds in winning 3 spell clashes in a row.\n", + "\n", + "Also, the spells now have a name and there is a dictionary that associates that name to a power.\n", + "\n", + "```\n", + "POWER = {\n", + " 'Fireball': 50, \n", + " 'Lightning bolt': 40, \n", + " 'Magic arrow': 10, \n", + " 'Black Tentacles': 25, \n", + " 'Contagion': 45\n", + "}\n", + "\n", + "gandalf = ['Fireball', 'Lightning bolt', 'Lightning bolt', 'Magic arrow', 'Fireball', \n", + " 'Magic arrow', 'Lightning bolt', 'Fireball', 'Fireball', 'Fireball']\n", + "saruman = ['Contagion', 'Contagion', 'Black Tentacles', 'Fireball', 'Black Tentacles', \n", + " 'Lightning bolt', 'Magic arrow', 'Contagion', 'Magic arrow', 'Magic arrow']\n", + "```\n", + "\n", + "#### 1. Create variables `POWER`, `gandalf` and `saruman` as seen above. Create a variable called `spells` to store the number of spells that the sorcerers cast. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "2jc2H9ExpeQN" + }, + "source": [ + "POWER = {\n", + " 'Fireball': 50, \n", + " 'Lightning bolt': 40, \n", + " 'Magic arrow': 10, \n", + " 'Black Tentacles': 25, \n", + " 'Contagion': 45\n", + "}\n", + "\n", + "gandalf = ['Fireball', 'Lightning bolt', 'Lightning bolt', 'Magic arrow', 'Fireball', \n", + " 'Magic arrow', 'Lightning bolt', 'Fireball', 'Fireball', 'Fireball']\n", + "saruman = ['Contagion', 'Contagion', 'Black Tentacles', 'Fireball', 'Black Tentacles', \n", + " 'Lightning bolt', 'Magic arrow', 'Contagion', 'Magic arrow', 'Magic arrow']\n", + "spells = 0" + ], + "execution_count": 10, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "GgzmoM74peQO" + }, + "source": [ + "#### 2. Create two variables called `gandalf_wins` and `saruman_wins`. Set both of them to 0. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "WX160BXqpeQO" + }, + "source": [ + "gandalf_wins = 0\n", + "saruman_wins = 0" + ], + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "W_13AxdFpeQO" + }, + "source": [ + "#### 3. Create two variables called `gandalf_power` and `saruman_power` to store the list of spell powers of each sorcerer." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "WT66_UDIpeQO" + }, + "source": [ + "gandalf_power = []\n", + "for i in gandalf:\n", + " gandalf_power.append(POWER[i])\n", + "saruman_power = []\n", + "for i in saruman:\n", + " saruman_power.append(POWER[i])" + ], + "execution_count": 13, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "zV-muqY-peQP" + }, + "source": [ + "#### 4. The battle starts! Using the variables you've created above, code the execution of spell clashes. Remember that a sorcerer wins if he succeeds in winning 3 spell clashes in a row. \n", + "If a clash ends up in a tie, the counter of wins in a row is not restarted to 0. Remember to print who is the winner of the battle. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "donBaJl9peQP", + "outputId": "8abea79a-eb11-4bc3-bc25-7164e0cc235c" + }, + "source": [ + "while gandalf_wins != 3 and saruman_wins != 3: \n", + " if gandalf_power[spells] > saruman_power[spells]:\n", + " gandalf_wins += 1\n", + " while gandalf_wins in [1,2]:\n", + " spells += 1\n", + " if gandalf_power[spells] > saruman_power[spells]:\n", + " gandalf_wins += 1\n", + " else:\n", + " gandalf_wins = 0\n", + " elif gandalf_power[spells] < saruman_power[spells]:\n", + " saruman_wins += 1\n", + " while saruman_wins in [1,2]:\n", + " spells += 1\n", + " if gandalf_power[spells] < saruman_power[spells]:\n", + " saruman_wins += 1\n", + " else:\n", + " saruman_wins = 0 \n", + "\n", + "if gandalf_wins > saruman_wins:\n", + " print(\"Gandalf wins\")\n", + "else:\n", + " print(\"Saruman wins\")" + ], + "execution_count": 14, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Gandalf wins\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Af-3InlipeQP" + }, + "source": [ + "#### 5. Find the average spell power of Gandalf and Saruman. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "GL97Iv2npeQP", + "outputId": "0c164e33-de6b-4c93-dfa0-b068a1f594c5" + }, + "source": [ + "from statistics import mean\n", + "print(f\"The average power of Gandalf is {round(mean(gandalf_power), 2)}, and Saruman's average power is {round(mean(saruman_power), 2)}\")" + ], + "execution_count": 16, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The average power of Gandalf is 39, and Saruman's average power is 30.5\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "6FB5Oc1PpeQP" + }, + "source": [ + "#### 6. Find the standard deviation of the spell power of Gandalf and Saruman. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "eEEpswIupeQP", + "outputId": "35e8d48c-8c61-4cb5-d13b-661adc16d861" + }, + "source": [ + "from statistics import stdev\n", + "print(f\"The standard deviation of powers of Gandalf's power is {round(stdev(gandalf_power), 2)}, while Saruman's is {round(stdev(saruman_power), 2)}\")\n", + "textest = 'urray'\n" + ], + "execution_count": 18, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The standard deviation of powers of Gandalf's power is 15.95, while Saruman's is 16.41\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From 6df8fa54edb5943f58e2ef4fbb2a7070228ee3d9 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 14:31:09 +0200 Subject: [PATCH 03/14] Created using Colaboratory --- bus.ipynb | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 bus.ipynb diff --git a/bus.ipynb b/bus.ipynb new file mode 100644 index 000000000..6d08f4186 --- /dev/null +++ b/bus.ipynb @@ -0,0 +1,216 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "bus.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "z_YHfQiB1XGF" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Q_SSvLI31XGI" + }, + "source": [ + "# Bus\n", + "\n", + "This bus has a passenger entry and exit control system to monitor the number of occupants it carries and thus detect when there are too many.\n", + "\n", + "At each stop, the entry and exit of passengers is represented by a tuple consisting of two integer numbers.\n", + "```\n", + "bus_stop = (in, out)\n", + "```\n", + "The succession of stops is represented by a list of these tuples.\n", + "```\n", + "stops = [(in1, out1), (in2, out2), (in3, out3), (in4, out4)]\n", + "```\n", + "\n", + "## Tools\n", + "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", + "* Data structures: **lists, tuples**\n", + "* Loop: **while/for loops**\n", + "* Functions: **min, max, len**\n", + "\n", + "## Tasks" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "lgNOzt3C1XGI" + }, + "source": [ + "# Variables\n", + "stops = [(10, 0), (4, 1), (3, 5), (3, 4), (5, 1), (1, 5), (5, 8), (4, 6), (2, 3)]\n", + "movement = []\n", + "occupation = []" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "rLzsRyFa1XGJ" + }, + "source": [ + "#### 1. Calculate the number of stops." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "C1qp08Vs1XGJ", + "outputId": "10cc9799-3dfe-4341-a491-f9754a8f1f91" + }, + "source": [ + "total_stops = len(stops)\n", + "print(\"The total number of bus stops is\", total_stops)" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The total number of bus stops is 9\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Kpvvz1w01XGK" + }, + "source": [ + "#### 2. Assign to a variable a list whose elements are the number of passengers at each stop (in-out).\n", + "Each item depends on the previous item in the list + in - out." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "X5VMevZr1XGK" + }, + "source": [ + "for up,down in stops:\n", + " movement.append(up - down)\n", + "\n", + "for i in range(total_stops):\n", + " occupation.append(sum(movement[0:i+1]))" + ], + "execution_count": 5, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "DQZrYZPd1XGK" + }, + "source": [ + "#### 3. Find the maximum occupation of the bus." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ueI7jmx01XGL", + "outputId": "2e938b3f-ccf2-4d20-9fbd-4dbf7b4f5b07" + }, + "source": [ + "print(\"The maximum occupation in the bus is\", max(occupation))" + ], + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The maximum occupation in the bus is 14\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Q2PgsIxM1XGL" + }, + "source": [ + "#### 4. Calculate the average occupation. And the standard deviation." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "0aVwHdMS1XGL", + "outputId": "6b16b77a-1198-46ec-9eea-8a9b8ceeca6b" + }, + "source": [ + "print(\"The average occupation is\", round((sum(occupation)/total_stops), 2))\n", + "import statistics\n", + "print(\"The standard deviation of the occupation is\", round(statistics.stdev(occupation), 2))" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The average occupation is 28.0\n", + "The standard deviation of the occupation is 3.26\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From cebca355c0c7affb01283fd5573ceb02999f5606 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 14:42:12 +0200 Subject: [PATCH 04/14] Created using Colaboratory --- robin_hood.ipynb | 279 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 robin_hood.ipynb diff --git a/robin_hood.ipynb b/robin_hood.ipynb new file mode 100644 index 000000000..1683b8aaf --- /dev/null +++ b/robin_hood.ipynb @@ -0,0 +1,279 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "robin-hood.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5Iylrv5g3OmC" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0OpeHAHt3OmF" + }, + "source": [ + "# Robin Hood\n", + "Robin Hood has entered a competition to win the archery contest in Sherwood. With his bow and arrows, he needs to shoot on a target and try to hit as close as possible to the center.\n", + "\n", + "![](images/arrows.jpg)\n", + "\n", + "## Context\n", + "In this challenge, the landing position of arrows shot by archers in the competition will be represented using 2-dimensional coordinates. \n", + "\n", + "In the 2-dimensional space, a point can be defined by a pair of values that correspond to the horizontal coordinate (x) and the vertical coordinate (y). For example, in our case, an arrow that hits the center of the archery target will land in position (0, 0) on the coordinate axes. \n", + "\n", + "The space can be divided into 4 zones (quadrants): Q1, Q2, Q3, Q4. If a point is in Q1, both its x coordinate and y coordinate are positive. Any point with a null x or y coordinate is considered to not belong to any quadrant. \n", + "\n", + "If you want to know more about the cartesian coordinate system, you can check this [link](https://en.wikipedia.org/wiki/Cartesian_coordinate_system). \n", + "\n", + "## Tools\n", + "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", + "* Data structures: **lists, sets, tuples**\n", + "* Conditional statements: **if-elif-else**\n", + "* Loop: **while/for**\n", + "* Minimum (optional sorting)\n", + "\n", + "## Tasks\n", + "Robin Hood has hit the following points:" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "fRvR5qj03OmG" + }, + "source": [ + "points = [(4, 5), (-0, 2), (4, 7), (1, -3), (3, -2), (4, 5), (3, 2), (5, 7), (-5, 7), (2, 2), (-4, 5), (0, -2),\n", + " (-4, 7), (-1, 3), (-3, 2), (-4, -5), (-3, 2), (5, 7), (5, 7), (2, 2), (9, 9), (-8, -9)]" + ], + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_YKX2NPm3OmG" + }, + "source": [ + "#### 1. Robin Hood is famous for hitting an arrow with another arrow. Find the coordinates of the points where an arrow hits another arrow." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "D0huQlsc3OmH", + "outputId": "5b668afe-8ac6-4fb2-9607-578abd5b489c" + }, + "source": [ + "bullseye = []\n", + "for i in range(len(points)):\n", + " if points[i] in points[i+1:]:\n", + " bullseye.append(points[i])\n", + "print(set(bullseye))" + ], + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "text": [ + "{(4, 5), (5, 7), (-3, 2), (2, 2)}\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4jjRMDPL3OmH" + }, + "source": [ + "#### 2. Calculate how many arrows have fallen in each quadrant. \n", + "**Note**: the arrows that fall in the axis (x=0 or y=0) don't belong to any quadrant." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "r1BOSax-3OmH", + "outputId": "3ad96f41-8235-4bca-fa41-3abfc86fd8d3" + }, + "source": [ + "q1 = []\n", + "q2 = []\n", + "q3 = []\n", + "q4 = []\n", + "count = 0\n", + "while count < len(points):\n", + " for hey,you in points[count:count+1]:\n", + " if hey > 0 and you > 0:\n", + " q1.append(points[count])\n", + " elif hey > 0 and you < 0:\n", + " q4.append(points[count])\n", + " elif hey < 0 and you > 0:\n", + " q2.append(points[count])\n", + " elif hey < 0 and you < 0:\n", + " q3.append(points[count])\n", + " count += 1\n", + "solution = \"There is a total of \" + str(len(q1)) + \" arrows in quadrant 1, \" + str(len(q2)) + \" arrows in quadrant 2, \" + str(len(q3)) + \" arrows in quadrant 3 and \" + str(len(q4)) + \" arrows in quadrant 4.\"\n", + "print(solution)\n", + "print(points[7:].index((5,7)))" + ], + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "text": [ + "There is a total of 10 arrows in quadrant 1, 6 arrows in quadrant 2, 2 arrows in quadrant 3 and 2 arrows in quadrant 4.\n", + "0\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "uhl9zx323OmI" + }, + "source": [ + "#### 3. Find the point closest to the center. Calculate its distance to the center. \n", + "Take into account that there might be more than one point at the minimum distance to the center.\n", + "\n", + "**Hint**: Use the Euclidean distance. You can find more information about it [here](https://en.wikipedia.org/wiki/Euclidean_distance). \n", + "**Hint**: Defining a function that calculates the distance to the center can help." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "7xcnOUB03OmI", + "outputId": "9ce0dc48-2186-4a92-cee8-e051fe4ef339" + }, + "source": [ + "##defining distance from center\n", + "\n", + "import math\n", + "def ramayana(shot):\n", + " hey = shot[0]\n", + " you = shot[1]\n", + " distance = math.sqrt(hey**2 + you**2)\n", + " return distance\n", + "\n", + "##creating list of distances\n", + "\n", + "distances = []\n", + "for i in points:\n", + " distances.append(round(ramayana(i), 2))\n", + "print(distances)\n", + "##creating list of closest points\n", + "\n", + "counter = 0\n", + "marksman = []\n", + "for i in distances:\n", + " if i == min(distances):\n", + " marksman.append(points[counter])\n", + " counter += 1 \n", + "\n", + "##printing solution\n", + "\n", + "print(\"The closest point(s) to the center is(are):\", marksman)\n", + "print(\"The distance of the closest point to the center is:\", min(distances))" + ], + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[6.4, 2.0, 8.06, 3.16, 3.61, 6.4, 3.61, 8.6, 8.6, 2.83, 6.4, 2.0, 8.06, 3.16, 3.61, 6.4, 3.61, 8.6, 8.6, 2.83, 12.73, 12.04]\n", + "The closest point(s) to the center is(are): [(0, 2), (0, -2)]\n", + "The distance of the closest point to the center is: 2.0\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hXzKW4h93OmI" + }, + "source": [ + "#### 4. If the archery target has a radius of 9, calculate the number of arrows that won't hit the target. \n", + "**Hint**: Use the function created in step 3. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EPcKF9j63OmJ", + "outputId": "d7282f6b-7d57-4953-80d2-31d6dd618306" + }, + "source": [ + "radius = 9\n", + "print(sum(1 for i in distances if i > radius), \"arrows didn't meet the target.\")" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "text": [ + "2 arrows didn't meet the target.\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From 562c3034c5fa5df8c22f6691b8ba77872f32da36 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:10:04 +0200 Subject: [PATCH 05/14] Created using Colaboratory --- temperature.ipynb | 484 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 484 insertions(+) create mode 100644 temperature.ipynb diff --git a/temperature.ipynb b/temperature.ipynb new file mode 100644 index 000000000..b1519b22c --- /dev/null +++ b/temperature.ipynb @@ -0,0 +1,484 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "temperature.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "k7vlVpG35PL-" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "f0xX-O8k5PMD" + }, + "source": [ + "# Temperature Sensor\n", + "\n", + "There is a temperature sensor in the processor of your company's server. The company wants to analyze the data provided by the sensor to decide if they should change the cooling system for a better one. As changing the cooling system is expensive and you are an excellent data analyst, you can't make a decision without basis.\n", + "\n", + "## Tools\n", + "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", + "1. Data structures: **lists**\n", + "2. Loops: **list comprehension**\n", + "3. Functions: **min, max, print, len**\n", + "4. Conditional statements: **if-elif-else**\n", + "\n", + "## Tasks\n", + "The temperatures measured throughout the 24 hours of a day are:" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "48pARpD75PME" + }, + "source": [ + "temperatures_C = [33, 66, 65, 0, 59, 60, 62, 64, 70, 76, 80, 81, 80, 83, 90, 79, 61, 53, 50, 49, 53, 48, 45, 39]" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "HE8xWI0_5PMF" + }, + "source": [ + "The first element of the list is the temperature at 12am, the second element is the temperature at 1am, and so on. \n", + "\n", + "The company has decided that if one of the following events occurs, then the cooling system needs to be replaced for a new one to avoid damaging the processor.\n", + "* More than 4 temperatures are greater than or equal to 70ºC.\n", + "* Any temperature is above 80ºC.\n", + "* The average temperature exceeds 65ºC.\n", + "\n", + "Follow the steps so that you can make the decision.\n", + "\n", + "#### 1. Find the minimum temperature of the day and store it in a variable." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "jRH4OMSH5PMF" + }, + "source": [ + "coldest = min(temperatures_C)" + ], + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "p9lwyJID5PMG" + }, + "source": [ + "#### 2. Find the maximum temperature of the day and store it in a variable." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "R9pMUpsi5PMG" + }, + "source": [ + "hottest = max(temperatures_C)" + ], + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "QTHGCW535PMG" + }, + "source": [ + "#### 3. Create a list with the temperatures that are greater than or equal to 70ºC. Store it in a variable." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "jJKXSKST5PMH" + }, + "source": [ + "hot_temps = [t for t in temperatures_C if t >= 70]" + ], + "execution_count": 5, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "z1JICZsP5PMH" + }, + "source": [ + "#### 4. Find the average temperature of the day and store it in a variable." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "sbniE6pv5PMI" + }, + "source": [ + "from statistics import mean\n", + "average = round(mean(temperatures_C), 2)" + ], + "execution_count": 6, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "R7RKovAj5PMI" + }, + "source": [ + "#### 5. Imagine that there was a sensor failure at 3am and the data for that specific hour was not recorded. How would you estimate the missing value? Replace the current value of the list at 3am for an estimation. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "n3RprhAu5PMJ", + "outputId": "66f2f579-4cf3-4bc4-ed56-3710b390d87c" + }, + "source": [ + "temperatures_C[3] = (temperatures_C[2] + temperatures_C[4])/2\n", + "print(temperatures_C)" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[33, 66, 65, 62.0, 59, 60, 62, 64, 70, 76, 80, 81, 80, 83, 90, 79, 61, 53, 50, 49, 53, 48, 45, 39]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pehKVIBg5PMJ" + }, + "source": [ + "#### 6. Bonus: the maintenance staff is from the United States and does not understand the international metric system. Help them by converting the temperatures from Celsius to Fahrenheit.\n", + "To know more about temperature conversion check this [link](https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature).\n", + "\n", + "**Formula**: \n", + "\n", + "$F = 1.8 * C + 32$" + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "mqIDXKSX5PMK", + "outputId": "70fe17fe-379e-4171-a3d5-5c84222909f8" + }, + "source": [ + "temperatures_F = [round(x*1.8 + 32) for x in temperatures_C]\n", + "print(temperatures_F)" + ], + "execution_count": 8, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[91, 151, 149, 144, 138, 140, 144, 147, 158, 169, 176, 178, 176, 181, 194, 174, 142, 127, 122, 120, 127, 118, 113, 102]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "7Qy15Nfl5PMK" + }, + "source": [ + "#### 7. Make a decision!\n", + "Now it's time to make a decision taking into account what you have seen until now. \n", + "\n", + "Remember that if one of the following events occurs, then the cooling system needs to be replaced for a new one to avoid damaging the processor.\n", + "* More than 4 temperatures are greater than or equal to 70ºC.\n", + "* Any temperature is above 80ºC.\n", + "* The average temperature exceeds 65ºC.\n", + "\n", + "#### To make your decision, check if any of the three conditions above is met. You might need to use some of the variables you created in steps 1 to 6. Print a message to show if the cooling system needs to be changed or not." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ZlkCvFa15PMK", + "outputId": "fec76cfb-547d-4231-98da-cc2d20229b45" + }, + "source": [ + "if len(hot_ones) >= 4 or m >= 80 in temperatures_C or average >= 65:\n", + " print(\"The Server is overheating. Cooling system need to be changed.\")\n", + "else:\n", + " print(\"Your server is cool. The cooling system needs not to be cahnged.\")" + ], + "execution_count": 9, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The Server is overheating. Cooling system need to be changed.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "jqHc7gQN5PMK" + }, + "source": [ + "## Bonus\n", + "\n", + "The company has decided that the decision you made is not valid. They want you to analyze the data again but this time, the conditions that need to be met in order to change the cooling system are different.\n", + "\n", + "This time, if one of the following events occurs, then the cooling system needs to be replaced:\n", + "* The temperature is greater than 70ºC during more than 4 consecutive hours.\n", + "* Any temperature is above 80ºC.\n", + "* The average temperature exceeds 65ºC.\n", + "\n", + "Follow the steps so that you can make the decision.\n", + "\n", + "#### 1. Create a list with the hours where the temperature is greater than 70ºC. Store it in a variable." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "RrKf9x8O5PMK", + "outputId": "62db9cc7-ed15-4ea4-b70f-7b03da8d6f1c" + }, + "source": [ + "beyond70 = []\n", + "for i in range(len(temperatures_C)):\n", + " if temperatures_C[i] > 70:\n", + " if i == 0:\n", + " beyond70.append('12 A.M.')\n", + " elif i > 12:\n", + " beyond70.append(str(i - 12) + ' P.M.')\n", + " elif i == 12:\n", + " beyond70.append(str(i) + ' P.M.')\n", + " else:\n", + " beyond70.append(str(i) + ' A.M.')\n", + "print(beyond70)" + ], + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "text": [ + "['9 A.M.', '10 A.M.', '11 A.M.', '12 P.M.', '1 P.M.', '2 P.M.', '3 P.M.']\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "7eqRa8GM5PML" + }, + "source": [ + "#### 2. Check if the list you created in step 1 has more than 4 consecutive hours. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "UMPFeTkY5PML", + "outputId": "faf7a61a-6818-4ce9-abea-e7870b0c1efa" + }, + "source": [ + "print(f'There were {len(beyond70)} hours with temperatures above 70 C.')" + ], + "execution_count": 11, + "outputs": [ + { + "output_type": "stream", + "text": [ + "There were 7 hours with temperatures above 70 C.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "fRZwk6Kc5PML" + }, + "source": [ + "#### 3. Make the decision!\n", + "To make your decision, check if any of the three conditions is met. Print a message to show if the cooling system needs to be changed or not." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Iq8tx2JW5PML", + "outputId": "c64deac4-104c-4f9b-ac0e-ffbddabddf01" + }, + "source": [ + "consexecution = 0\n", + "counter = 0\n", + "while consexecution < 4 and len(temperatures_C) != (counter + 1):\n", + " if temperatures_C[counter] >= 70:\n", + " consexecution += 1\n", + " else:\n", + " consexecution = 0\n", + " counter += 1\n", + "\n", + "if consexecution >= 4 or m >= 80 in temperatures_C or average >= 65:\n", + " print(\"Server under overheating hazard. Please change the cooling system.\")\n", + "else:\n", + " print(\"Cooling system effective. Your server is cool.\")" + ], + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Server under overheating hazard. Please change the cooling system.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Il0EmrFe5PML" + }, + "source": [ + "#### 4. Find the average value of the temperature lists (ºC and ºF). What is the relation between both average values?" + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "WiYAUa9d5PML", + "outputId": "b1c42bd9-5bc5-4060-b196-46b75426596f" + }, + "source": [ + "from statistics import mean\n", + "print(f'The average temperature in C is {round(mean(temperatures_C), 2)}, and the average temperature in F is {round(mean(temperatures_F), 2)}, \\nwhich means that, in average, the measured temperatures in F are {round(mean(temperatures_F)/mean(temperatures_C), 2)} greater than the temperatures in C.')" + ], + "execution_count": 13, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The average temperature in C is 62.83, and the average temperature in F is 145.04, \n", + "which means that, in average, the measured temperatures in F are 2.31 greater than the temperatures in C.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "owlqj1Pq5PML" + }, + "source": [ + "#### 5. Find the standard deviation of the temperature lists (ºC and ºF). What is the relation between both standard deviations?" + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "lku9116m5PMM", + "outputId": "78064f9a-6940-4b81-c1a3-fa371027acfc" + }, + "source": [ + "from statistics import stdev\n", + "print(f'The standard deviation of the measured temperatures in C is {round(stdev(temperatures_C), 2)}, and the standard deviation in F is {round(stdev(temperatures_F), 2)}, \\nwhich means that the standard deviation in F is {round(stdev(temperatures_F)/stdev(temperatures_C), 2)} greater than with the temperatures in C.')" + ], + "execution_count": 14, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The standard deviation of the measured temperatures in C is 14.95, and the standard deviation in F is 26.99, \n", + "which means that the standard deviation in F is 1.81 greater than with the temperatures in C.\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From 35134d433395b3746b721634c2a1705aaf4be3d2 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Tue, 13 Jul 2021 16:19:40 +0200 Subject: [PATCH 06/14] Created using Colaboratory --- rock_paper_scissors.ipynb | 471 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 471 insertions(+) create mode 100644 rock_paper_scissors.ipynb diff --git a/rock_paper_scissors.ipynb b/rock_paper_scissors.ipynb new file mode 100644 index 000000000..fb7a1d8a3 --- /dev/null +++ b/rock_paper_scissors.ipynb @@ -0,0 +1,471 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.2" + }, + "colab": { + "name": "rock-paper-scissors.ipynb", + "provenance": [], + "include_colab_link": true + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KvIpODej_d-6" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gqebzgki_d--" + }, + "source": [ + "# Rock, Paper & Scissors\n", + "\n", + "Let's play the famous game against our computer. You can check the rules [here](https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors). \n", + "\n", + "## Task\n", + "Create a program that imitates the playability of the well known game of rock, paper, scissors. Follow the guidelines provided.\n", + "\n", + "## Tools\n", + "1. Loop: **for/while**\n", + "2. Functions: **input(), print()...**\n", + "3. Conditional statements: **if, elif, else**\n", + "4. Definition of functions. Modular programming\n", + "5. Import modules\n", + "\n", + "**To solve this challenge, the use of functions is recommended.**\n", + "\n", + "#### 1. Import the choice function of the random module." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "ZiEU3fHV_d_A" + }, + "source": [ + "from random import choice" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "VDC0N5a0_d_B" + }, + "source": [ + "#### 2. Create a list that includes the 3 possible gesture options of the game: 'rock', 'paper' or 'scissors'. Store the list in a variable called `gestures`." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "pBx3E3MU_d_B" + }, + "source": [ + "gestures = ['rock','paper','scissors']" + ], + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "smmbuxKf_d_B" + }, + "source": [ + "#### 3. Create a variable called `n_rounds` to store the maximum number of rounds to play in a game. \n", + "Remember that the number of rounds must be odd: 1, 3, 5, ..." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ToHgKbpa_d_C", + "outputId": "26324ed9-1fad-48aa-b969-a13ae7ea6c1b" + }, + "source": [ + "n_rounds = input(\"How many rounds you want to play? (Hint: should be an odd number) >>> \")\n", + "try:\n", + " n_rounds = int(n_rounds)\n", + " if n_rounds % 2 == 0:\n", + " print(\"That is so NOT an odd number...\")\n", + " n_rounds = 0\n", + " elif n_rounds > 10:\n", + " print(\"I don't have time. Let's try less than 10.\")\n", + " n_rounds = 0\n", + " else:\n", + " print(\"Alright! Let's play \", int(n_rounds), \" rounds.\")\n", + "except ValueError:\n", + " print(\"To play \", n_rounds, \" rounds I'd have to slice your hand in pieces, honey.\")\n", + " n_rounds = 0" + ], + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "text": [ + "How many rounds you want to play? (Hint: should be an odd number) >>> 3\n", + "Alright! Let's play 3 rounds.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_Njh5SyN_d_C" + }, + "source": [ + "#### 4. Create a variable called `rounds_to_win` to store the number of rounds that a player must win to win the game.\n", + "**Hint**: the value stored in `rounds_to_win` depends on the value of `n_rounds`. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Z-bzVok2_d_C" + }, + "source": [ + "import math\n", + "rounds_to_win = math.ceil(n_rounds/2)" + ], + "execution_count": 10, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-6zf6RU5_d_D" + }, + "source": [ + "#### 5. Create two variables to store the number of rounds that the computer and the player have won. Call these variables `cpu_score` and `player_score`." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "BRxqrJW2_d_D" + }, + "source": [ + "cpu_score = 0\n", + "player_score = 0" + ], + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cvuFoT65_d_D" + }, + "source": [ + "#### 6. Define a function that randomly returns one of the 3 gesture options.\n", + "You will use this function to simulate the gesture choice of the computer. " + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "-1NFUQFg_d_E" + }, + "source": [ + "### w should be the list of posible gestures\n", + "def T800(w):\n", + " return choice(w);" + ], + "execution_count": 15, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "eiNNv_2c_d_E" + }, + "source": [ + "#### 7. Define a function that asks the player which is the gesture he or she wants to show: 'rock', 'paper' or 'scissors'.\n", + "The player should only be allowed to choose one of the 3 gesture options. If the player's choice is not rock, paper or scissors, keep asking until it is." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "wg62Ko7l_d_E" + }, + "source": [ + "### x should also be the gesture options\n", + "def shand(x):\n", + " player = 0\n", + " while player == 0:\n", + " player = input(\"Please choose wisely: \" + str(x) + \" >>> \")\n", + " if player in x:\n", + " return player\n", + " else:\n", + " print(\"You fool. Play by the rules.\")\n", + " player = 0" + ], + "execution_count": 16, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Vvs4x5z9_d_E" + }, + "source": [ + "#### 8. Define a function that checks who won a round. \n", + "The function should return 0 if there is a tie, 1 if the computer wins and 2 if the player wins." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "yikw2Vvh_d_E" + }, + "source": [ + "joy = {'rock':['scissors'], 'paper':['rock'], 'scissors':['paper']}\n", + "### y should be the winning dictionary\n", + "def winner(y):\n", + " outcome = 2\n", + " if player == quick_thumb:\n", + " outcome = 0\n", + " elif player in y[quick_thumb]:\n", + " outcome = 1\n", + " return outcome" + ], + "execution_count": 17, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "8RKDPGXr_d_F" + }, + "source": [ + "#### 9. Define a function that prints the choice of the computer, the choice of the player and a message that announces who won the current round. \n", + "You should also use this function to update the variables that count the number of rounds that the computer and the player have won. The score of the winner increases by one point. If there is a tie, the score does not increase." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "SLhPrL_J_d_F" + }, + "source": [ + "### z should be the outcome of the 'winner' function\n", + "def roundin(z):\n", + " result = {0:'Tie!',1:'I win.',2:'You win.'}\n", + " print('You chose ' + player)\n", + " print('I chose ' + quick_thumb)\n", + " print(result[z])" + ], + "execution_count": 18, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZwuFjPhC_d_F" + }, + "source": [ + "#### 10. Now it's time to code the execution of the game using the functions and variables you defined above. \n", + "\n", + "First, create a loop structure that repeats while no player reaches the minimum score necessary to win and the number of rounds is less than the maximum number of rounds to play in a game. \n", + "\n", + "Inside the loop, use the functions and variables above to create the execution of a round: ask for the player's choice, generate the random choice of the computer, show the round results, update the scores, etc. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EtvtiYq9_d_F", + "outputId": "cacb87b2-f8fb-49e4-e1cb-4f43b5b3e35f" + }, + "source": [ + "rounds_done = 0\n", + "while rounds_done < n_rounds and cpu_score < rounds_to_win and player_score < rounds_to_win:\n", + " player = shand(gestures)\n", + " quick_thumb = T800(gestures)\n", + " outcome = winner(joy)\n", + " roundin(outcome)\n", + " rounds_done += 1\n", + " if outcome == 1:\n", + " cpu_score += 1\n", + " elif outcome == 2:\n", + " player_score += 1\n" + ], + "execution_count": 19, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Please choose wisely: ['rock', 'paper', 'scissors'] >>> rock\n", + "You chose rock\n", + "I chose rock\n", + "Tie!\n", + "Please choose wisely: ['rock', 'paper', 'scissors'] >>> paper\n", + "You chose paper\n", + "I chose scissors\n", + "I win.\n", + "Please choose wisely: ['rock', 'paper', 'scissors'] >>> rock\n", + "You chose rock\n", + "I chose rock\n", + "Tie!\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9J-rI54X_d_F" + }, + "source": [ + "#### 11. Print the winner of the game based on who won more rounds.\n", + "Remember that the game might be tied. " + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "5ak5tH58_d_F", + "outputId": "dd91d7d9-3b72-45fc-ad99-6ad8516897e0" + }, + "source": [ + "if player_score >= cpu_score:\n", + " print(\"You win. \\nThor: 'Loki, my mind is going.'\")\n", + "elif cpu_score >= player_score:\n", + " print(\"CPU wins! \\nThe Instructor: 'So did the man went down with his choice.'\")\n", + "else:\n", + " print(\"Tie.\")" + ], + "execution_count": 22, + "outputs": [ + { + "output_type": "stream", + "text": [ + "CPU wins! \n", + "The Instructor: 'So did the man went down with his choice.'\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "vYLAdCkq_d_F" + }, + "source": [ + "# Bonus: Rock, Paper, Scissors, Lizard & Spock\n", + "![](images/rpsls.jpg)\n", + "\n", + "In this challenge, you need to improve the previous game by adding two new options. To know more about the rules of the improved version of rock, paper, scissors, check this [link](http://www.samkass.com/theories/RPSSL.html). \n", + "\n", + "In addition, you will also need to improve how the game interacts with the player: the number of rounds to play, which must be an odd number, will be requested to the user until a valid number is entered. Define a new function to make that request.\n", + "\n", + "**Hint**: Try to reuse the code that you already coded in the previous challenge. If your code is efficient, this bonus will only consist of simple modifications to the original game." + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6Fv-Y4kS_d_G", + "outputId": "90f6b59c-bef5-4ad5-a4d9-fef8f5c8f421" + }, + "source": [ + "gestures2 = ['rock','paper','scissors','lizard','spock']\n", + "joy2 = {'rock':['scissors','lizard'], 'paper':['rock','spock'], 'scissors':['paper','lizard'], 'lizard':['spock','paper'],'spock':['rock','scissors']}\n", + "cpu_score = 0\n", + "player_score = 0\n", + "rounds_done = 0\n", + "while rounds_done < n_rounds and cpu_score < rounds_to_win and player_score < rounds_to_win:\n", + " player = shand(gestures2)\n", + " quick_thumb = T800(gestures2)\n", + " outcome = winner(joy2)\n", + " roundin(outcome)\n", + " rounds_done += 1\n", + " if outcome == 1:\n", + " cpu_score += 1\n", + " elif outcome == 2:\n", + " player_score += 1\n", + "if player_score >= cpu_score:\n", + " print(\"You won... \\nThor: 'Loki, my mind is going crazy.'\")\n", + "elif cpu_score >= player_score:\n", + " print(\"CPU wins! \\nThe Instructor: 'So did the man went down with his choice.'\")\n", + "else:\n", + " print(\"Tie.\")" + ], + "execution_count": 25, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> rock\n", + "You chose rock\n", + "I chose lizard\n", + "You win.\n", + "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> scissors\n", + "You chose scissors\n", + "I chose rock\n", + "I win.\n", + "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> lizard\n", + "You chose lizard\n", + "I chose spock\n", + "You win.\n", + "You won... \n", + "Thor: 'Loki, my mind is going crazy.'\n" + ], + "name": "stdout" + } + ] + } + ] +} \ No newline at end of file From 28108d857e9cfe299be089a2fdcba454b32da697 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:47:59 +0200 Subject: [PATCH 07/14] Delete temperature.ipynb --- temperature.ipynb | 484 ---------------------------------------------- 1 file changed, 484 deletions(-) delete mode 100644 temperature.ipynb diff --git a/temperature.ipynb b/temperature.ipynb deleted file mode 100644 index b1519b22c..000000000 --- a/temperature.ipynb +++ /dev/null @@ -1,484 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "temperature.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "k7vlVpG35PL-" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "f0xX-O8k5PMD" - }, - "source": [ - "# Temperature Sensor\n", - "\n", - "There is a temperature sensor in the processor of your company's server. The company wants to analyze the data provided by the sensor to decide if they should change the cooling system for a better one. As changing the cooling system is expensive and you are an excellent data analyst, you can't make a decision without basis.\n", - "\n", - "## Tools\n", - "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", - "1. Data structures: **lists**\n", - "2. Loops: **list comprehension**\n", - "3. Functions: **min, max, print, len**\n", - "4. Conditional statements: **if-elif-else**\n", - "\n", - "## Tasks\n", - "The temperatures measured throughout the 24 hours of a day are:" - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "48pARpD75PME" - }, - "source": [ - "temperatures_C = [33, 66, 65, 0, 59, 60, 62, 64, 70, 76, 80, 81, 80, 83, 90, 79, 61, 53, 50, 49, 53, 48, 45, 39]" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "HE8xWI0_5PMF" - }, - "source": [ - "The first element of the list is the temperature at 12am, the second element is the temperature at 1am, and so on. \n", - "\n", - "The company has decided that if one of the following events occurs, then the cooling system needs to be replaced for a new one to avoid damaging the processor.\n", - "* More than 4 temperatures are greater than or equal to 70ºC.\n", - "* Any temperature is above 80ºC.\n", - "* The average temperature exceeds 65ºC.\n", - "\n", - "Follow the steps so that you can make the decision.\n", - "\n", - "#### 1. Find the minimum temperature of the day and store it in a variable." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "jRH4OMSH5PMF" - }, - "source": [ - "coldest = min(temperatures_C)" - ], - "execution_count": 2, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "p9lwyJID5PMG" - }, - "source": [ - "#### 2. Find the maximum temperature of the day and store it in a variable." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "R9pMUpsi5PMG" - }, - "source": [ - "hottest = max(temperatures_C)" - ], - "execution_count": 3, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "QTHGCW535PMG" - }, - "source": [ - "#### 3. Create a list with the temperatures that are greater than or equal to 70ºC. Store it in a variable." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "jJKXSKST5PMH" - }, - "source": [ - "hot_temps = [t for t in temperatures_C if t >= 70]" - ], - "execution_count": 5, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "z1JICZsP5PMH" - }, - "source": [ - "#### 4. Find the average temperature of the day and store it in a variable." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "sbniE6pv5PMI" - }, - "source": [ - "from statistics import mean\n", - "average = round(mean(temperatures_C), 2)" - ], - "execution_count": 6, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "R7RKovAj5PMI" - }, - "source": [ - "#### 5. Imagine that there was a sensor failure at 3am and the data for that specific hour was not recorded. How would you estimate the missing value? Replace the current value of the list at 3am for an estimation. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "n3RprhAu5PMJ", - "outputId": "66f2f579-4cf3-4bc4-ed56-3710b390d87c" - }, - "source": [ - "temperatures_C[3] = (temperatures_C[2] + temperatures_C[4])/2\n", - "print(temperatures_C)" - ], - "execution_count": 7, - "outputs": [ - { - "output_type": "stream", - "text": [ - "[33, 66, 65, 62.0, 59, 60, 62, 64, 70, 76, 80, 81, 80, 83, 90, 79, 61, 53, 50, 49, 53, 48, 45, 39]\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "pehKVIBg5PMJ" - }, - "source": [ - "#### 6. Bonus: the maintenance staff is from the United States and does not understand the international metric system. Help them by converting the temperatures from Celsius to Fahrenheit.\n", - "To know more about temperature conversion check this [link](https://en.wikipedia.org/wiki/Conversion_of_units_of_temperature).\n", - "\n", - "**Formula**: \n", - "\n", - "$F = 1.8 * C + 32$" - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "mqIDXKSX5PMK", - "outputId": "70fe17fe-379e-4171-a3d5-5c84222909f8" - }, - "source": [ - "temperatures_F = [round(x*1.8 + 32) for x in temperatures_C]\n", - "print(temperatures_F)" - ], - "execution_count": 8, - "outputs": [ - { - "output_type": "stream", - "text": [ - "[91, 151, 149, 144, 138, 140, 144, 147, 158, 169, 176, 178, 176, 181, 194, 174, 142, 127, 122, 120, 127, 118, 113, 102]\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "7Qy15Nfl5PMK" - }, - "source": [ - "#### 7. Make a decision!\n", - "Now it's time to make a decision taking into account what you have seen until now. \n", - "\n", - "Remember that if one of the following events occurs, then the cooling system needs to be replaced for a new one to avoid damaging the processor.\n", - "* More than 4 temperatures are greater than or equal to 70ºC.\n", - "* Any temperature is above 80ºC.\n", - "* The average temperature exceeds 65ºC.\n", - "\n", - "#### To make your decision, check if any of the three conditions above is met. You might need to use some of the variables you created in steps 1 to 6. Print a message to show if the cooling system needs to be changed or not." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "ZlkCvFa15PMK", - "outputId": "fec76cfb-547d-4231-98da-cc2d20229b45" - }, - "source": [ - "if len(hot_ones) >= 4 or m >= 80 in temperatures_C or average >= 65:\n", - " print(\"The Server is overheating. Cooling system need to be changed.\")\n", - "else:\n", - " print(\"Your server is cool. The cooling system needs not to be cahnged.\")" - ], - "execution_count": 9, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The Server is overheating. Cooling system need to be changed.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "jqHc7gQN5PMK" - }, - "source": [ - "## Bonus\n", - "\n", - "The company has decided that the decision you made is not valid. They want you to analyze the data again but this time, the conditions that need to be met in order to change the cooling system are different.\n", - "\n", - "This time, if one of the following events occurs, then the cooling system needs to be replaced:\n", - "* The temperature is greater than 70ºC during more than 4 consecutive hours.\n", - "* Any temperature is above 80ºC.\n", - "* The average temperature exceeds 65ºC.\n", - "\n", - "Follow the steps so that you can make the decision.\n", - "\n", - "#### 1. Create a list with the hours where the temperature is greater than 70ºC. Store it in a variable." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "RrKf9x8O5PMK", - "outputId": "62db9cc7-ed15-4ea4-b70f-7b03da8d6f1c" - }, - "source": [ - "beyond70 = []\n", - "for i in range(len(temperatures_C)):\n", - " if temperatures_C[i] > 70:\n", - " if i == 0:\n", - " beyond70.append('12 A.M.')\n", - " elif i > 12:\n", - " beyond70.append(str(i - 12) + ' P.M.')\n", - " elif i == 12:\n", - " beyond70.append(str(i) + ' P.M.')\n", - " else:\n", - " beyond70.append(str(i) + ' A.M.')\n", - "print(beyond70)" - ], - "execution_count": 10, - "outputs": [ - { - "output_type": "stream", - "text": [ - "['9 A.M.', '10 A.M.', '11 A.M.', '12 P.M.', '1 P.M.', '2 P.M.', '3 P.M.']\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "7eqRa8GM5PML" - }, - "source": [ - "#### 2. Check if the list you created in step 1 has more than 4 consecutive hours. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "UMPFeTkY5PML", - "outputId": "faf7a61a-6818-4ce9-abea-e7870b0c1efa" - }, - "source": [ - "print(f'There were {len(beyond70)} hours with temperatures above 70 C.')" - ], - "execution_count": 11, - "outputs": [ - { - "output_type": "stream", - "text": [ - "There were 7 hours with temperatures above 70 C.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "fRZwk6Kc5PML" - }, - "source": [ - "#### 3. Make the decision!\n", - "To make your decision, check if any of the three conditions is met. Print a message to show if the cooling system needs to be changed or not." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "Iq8tx2JW5PML", - "outputId": "c64deac4-104c-4f9b-ac0e-ffbddabddf01" - }, - "source": [ - "consexecution = 0\n", - "counter = 0\n", - "while consexecution < 4 and len(temperatures_C) != (counter + 1):\n", - " if temperatures_C[counter] >= 70:\n", - " consexecution += 1\n", - " else:\n", - " consexecution = 0\n", - " counter += 1\n", - "\n", - "if consexecution >= 4 or m >= 80 in temperatures_C or average >= 65:\n", - " print(\"Server under overheating hazard. Please change the cooling system.\")\n", - "else:\n", - " print(\"Cooling system effective. Your server is cool.\")" - ], - "execution_count": 12, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Server under overheating hazard. Please change the cooling system.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Il0EmrFe5PML" - }, - "source": [ - "#### 4. Find the average value of the temperature lists (ºC and ºF). What is the relation between both average values?" - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "WiYAUa9d5PML", - "outputId": "b1c42bd9-5bc5-4060-b196-46b75426596f" - }, - "source": [ - "from statistics import mean\n", - "print(f'The average temperature in C is {round(mean(temperatures_C), 2)}, and the average temperature in F is {round(mean(temperatures_F), 2)}, \\nwhich means that, in average, the measured temperatures in F are {round(mean(temperatures_F)/mean(temperatures_C), 2)} greater than the temperatures in C.')" - ], - "execution_count": 13, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The average temperature in C is 62.83, and the average temperature in F is 145.04, \n", - "which means that, in average, the measured temperatures in F are 2.31 greater than the temperatures in C.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "owlqj1Pq5PML" - }, - "source": [ - "#### 5. Find the standard deviation of the temperature lists (ºC and ºF). What is the relation between both standard deviations?" - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "lku9116m5PMM", - "outputId": "78064f9a-6940-4b81-c1a3-fa371027acfc" - }, - "source": [ - "from statistics import stdev\n", - "print(f'The standard deviation of the measured temperatures in C is {round(stdev(temperatures_C), 2)}, and the standard deviation in F is {round(stdev(temperatures_F), 2)}, \\nwhich means that the standard deviation in F is {round(stdev(temperatures_F)/stdev(temperatures_C), 2)} greater than with the temperatures in C.')" - ], - "execution_count": 14, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The standard deviation of the measured temperatures in C is 14.95, and the standard deviation in F is 26.99, \n", - "which means that the standard deviation in F is 1.81 greater than with the temperatures in C.\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From 365e11769c3e020db859ef570e8f7829485942e2 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:48:10 +0200 Subject: [PATCH 08/14] Delete snail_and_well.ipynb --- snail_and_well.ipynb | 310 ------------------------------------------- 1 file changed, 310 deletions(-) delete mode 100644 snail_and_well.ipynb diff --git a/snail_and_well.ipynb b/snail_and_well.ipynb deleted file mode 100644 index ea5242b86..000000000 --- a/snail_and_well.ipynb +++ /dev/null @@ -1,310 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "snail-and-well.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "t3IR-fi_cuUY" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "aiiwtz5qcuUf" - }, - "source": [ - "# The Snail and the Well\n", - "\n", - "A snail falls at the bottom of a 125 cm well. Each day the snail rises 30 cm. But at night, while sleeping, slides 20 cm because the walls are wet. How many days does it take for the snail to escape the well?\n", - "\n", - "**Hint**: The snail gets out of the well when it surpasses the 125cm of height.\n", - "\n", - "## Tools\n", - "\n", - "1. Loop: **while**\n", - "2. Conditional statements: **if-else**\n", - "3. Function: **print()**\n", - "\n", - "## Tasks\n", - "\n", - "#### 1. Assign the challenge data to variables with representative names: `well_height`, `daily_distance`, `nightly_distance` and `snail_position`." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "lkrJWkYPcuUh" - }, - "source": [ - "well_height = 125\n", - "daily_distance = 30\n", - "nightly_distance = 20\n", - "snail_position = 0" - ], - "execution_count": 11, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "8TYYAMvkcuUj" - }, - "source": [ - "#### 2. Create a variable `days` to keep count of the days that pass until the snail escapes the well. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "pn6aSYtMcuUk" - }, - "source": [ - "days = 0" - ], - "execution_count": 12, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "DQPuRPmlcuUk" - }, - "source": [ - "#### 3. Find the solution to the challenge using the variables defined above. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "p9dWhmaLcuUl" - }, - "source": [ - "while True:\n", - " days += 1\n", - " snail_position += daily_distance\n", - " if snail_position >= well_height:\n", - " break\n", - " snail_position -= nightly_distance\n" - ], - "execution_count": 13, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "x-qxoqr1cuUm" - }, - "source": [ - "#### 4. Print the solution." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "WMNZokjocuUn", - "outputId": "713024cd-757d-4fe5-be1d-68192f927442" - }, - "source": [ - "print(days)" - ], - "execution_count": 14, - "outputs": [ - { - "output_type": "stream", - "text": [ - "11\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ST5OEgo-cuUn" - }, - "source": [ - "## Bonus\n", - "The distance traveled by the snail each day is now defined by a list.\n", - "```\n", - "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", - "```\n", - "On the first day, the snail rises 30cm but during the night it slides 20cm. On the second day, the snail rises 21cm but during the night it slides 20cm, and so on. \n", - "\n", - "#### 1. How many days does it take for the snail to escape the well?\n", - "Follow the same guidelines as in the previous challenge.\n", - "\n", - "**Hint**: Remember that the snail gets out of the well when it surpasses the 125cm of height." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "phDzTBUjcuUo", - "outputId": "3bea97f7-670d-4966-ad65-1aec80c285d5" - }, - "source": [ - "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", - "print(len(advance_cm))\n" - ], - "execution_count": 15, - "outputs": [ - { - "output_type": "stream", - "text": [ - "11\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "9yDTFImycuUp" - }, - "source": [ - "#### 2. What is its maximum displacement in one day? And its minimum? Calculate the displacement using only the travel distance of the days used to get out of the well. \n", - "**Hint**: Remember that displacement means the total distance risen taking into account that the snail slides at night. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "S4WgF__ZcuUp", - "outputId": "97e9549f-0f1b-4579-de15-8e7a1f9fcd3c" - }, - "source": [ - "advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", - "print(max(advance_cm))" - ], - "execution_count": 16, - "outputs": [ - { - "output_type": "stream", - "text": [ - "77\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZvcXEZZ_cuUq" - }, - "source": [ - "#### 3. What is its average progress? Take into account the snail slides at night." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "TyTm03S2cuUq", - "outputId": "de082c0b-418a-43c3-df49-79d0e22be710" - }, - "source": [ - "advance_cm =[30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", - "num = sum(advance_cm)\n", - "den = len(advance_cm)\n", - "avg = num / den\n", - "print(avg)\n" - ], - "execution_count": 17, - "outputs": [ - { - "output_type": "stream", - "text": [ - "38.09090909090909\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "CP--AUP5cuUr" - }, - "source": [ - "#### 4. What is the standard deviation of its displacement? Take into account the snail slides at night." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "JeyUTfgWcuUr", - "outputId": "b69d0d7e-3ecd-4885-e05a-d88d21012694" - }, - "source": [ - "import numpy as np\n", - "advance_cm =[30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]\n", - "print(np.std(advance_cm))" - ], - "execution_count": 18, - "outputs": [ - { - "output_type": "stream", - "text": [ - "17.159437082600803\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From ecaec2fbab5625491d32493926c2bc5b8ed8b64f Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:48:20 +0200 Subject: [PATCH 09/14] Delete rock_paper_scissors.ipynb --- rock_paper_scissors.ipynb | 471 -------------------------------------- 1 file changed, 471 deletions(-) delete mode 100644 rock_paper_scissors.ipynb diff --git a/rock_paper_scissors.ipynb b/rock_paper_scissors.ipynb deleted file mode 100644 index fb7a1d8a3..000000000 --- a/rock_paper_scissors.ipynb +++ /dev/null @@ -1,471 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "rock-paper-scissors.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "KvIpODej_d-6" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "gqebzgki_d--" - }, - "source": [ - "# Rock, Paper & Scissors\n", - "\n", - "Let's play the famous game against our computer. You can check the rules [here](https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors). \n", - "\n", - "## Task\n", - "Create a program that imitates the playability of the well known game of rock, paper, scissors. Follow the guidelines provided.\n", - "\n", - "## Tools\n", - "1. Loop: **for/while**\n", - "2. Functions: **input(), print()...**\n", - "3. Conditional statements: **if, elif, else**\n", - "4. Definition of functions. Modular programming\n", - "5. Import modules\n", - "\n", - "**To solve this challenge, the use of functions is recommended.**\n", - "\n", - "#### 1. Import the choice function of the random module." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "ZiEU3fHV_d_A" - }, - "source": [ - "from random import choice" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "VDC0N5a0_d_B" - }, - "source": [ - "#### 2. Create a list that includes the 3 possible gesture options of the game: 'rock', 'paper' or 'scissors'. Store the list in a variable called `gestures`." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "pBx3E3MU_d_B" - }, - "source": [ - "gestures = ['rock','paper','scissors']" - ], - "execution_count": 2, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "smmbuxKf_d_B" - }, - "source": [ - "#### 3. Create a variable called `n_rounds` to store the maximum number of rounds to play in a game. \n", - "Remember that the number of rounds must be odd: 1, 3, 5, ..." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "ToHgKbpa_d_C", - "outputId": "26324ed9-1fad-48aa-b969-a13ae7ea6c1b" - }, - "source": [ - "n_rounds = input(\"How many rounds you want to play? (Hint: should be an odd number) >>> \")\n", - "try:\n", - " n_rounds = int(n_rounds)\n", - " if n_rounds % 2 == 0:\n", - " print(\"That is so NOT an odd number...\")\n", - " n_rounds = 0\n", - " elif n_rounds > 10:\n", - " print(\"I don't have time. Let's try less than 10.\")\n", - " n_rounds = 0\n", - " else:\n", - " print(\"Alright! Let's play \", int(n_rounds), \" rounds.\")\n", - "except ValueError:\n", - " print(\"To play \", n_rounds, \" rounds I'd have to slice your hand in pieces, honey.\")\n", - " n_rounds = 0" - ], - "execution_count": 5, - "outputs": [ - { - "output_type": "stream", - "text": [ - "How many rounds you want to play? (Hint: should be an odd number) >>> 3\n", - "Alright! Let's play 3 rounds.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_Njh5SyN_d_C" - }, - "source": [ - "#### 4. Create a variable called `rounds_to_win` to store the number of rounds that a player must win to win the game.\n", - "**Hint**: the value stored in `rounds_to_win` depends on the value of `n_rounds`. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "Z-bzVok2_d_C" - }, - "source": [ - "import math\n", - "rounds_to_win = math.ceil(n_rounds/2)" - ], - "execution_count": 10, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "-6zf6RU5_d_D" - }, - "source": [ - "#### 5. Create two variables to store the number of rounds that the computer and the player have won. Call these variables `cpu_score` and `player_score`." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "BRxqrJW2_d_D" - }, - "source": [ - "cpu_score = 0\n", - "player_score = 0" - ], - "execution_count": 11, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "cvuFoT65_d_D" - }, - "source": [ - "#### 6. Define a function that randomly returns one of the 3 gesture options.\n", - "You will use this function to simulate the gesture choice of the computer. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "-1NFUQFg_d_E" - }, - "source": [ - "### w should be the list of posible gestures\n", - "def T800(w):\n", - " return choice(w);" - ], - "execution_count": 15, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "eiNNv_2c_d_E" - }, - "source": [ - "#### 7. Define a function that asks the player which is the gesture he or she wants to show: 'rock', 'paper' or 'scissors'.\n", - "The player should only be allowed to choose one of the 3 gesture options. If the player's choice is not rock, paper or scissors, keep asking until it is." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "wg62Ko7l_d_E" - }, - "source": [ - "### x should also be the gesture options\n", - "def shand(x):\n", - " player = 0\n", - " while player == 0:\n", - " player = input(\"Please choose wisely: \" + str(x) + \" >>> \")\n", - " if player in x:\n", - " return player\n", - " else:\n", - " print(\"You fool. Play by the rules.\")\n", - " player = 0" - ], - "execution_count": 16, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Vvs4x5z9_d_E" - }, - "source": [ - "#### 8. Define a function that checks who won a round. \n", - "The function should return 0 if there is a tie, 1 if the computer wins and 2 if the player wins." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "yikw2Vvh_d_E" - }, - "source": [ - "joy = {'rock':['scissors'], 'paper':['rock'], 'scissors':['paper']}\n", - "### y should be the winning dictionary\n", - "def winner(y):\n", - " outcome = 2\n", - " if player == quick_thumb:\n", - " outcome = 0\n", - " elif player in y[quick_thumb]:\n", - " outcome = 1\n", - " return outcome" - ], - "execution_count": 17, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "8RKDPGXr_d_F" - }, - "source": [ - "#### 9. Define a function that prints the choice of the computer, the choice of the player and a message that announces who won the current round. \n", - "You should also use this function to update the variables that count the number of rounds that the computer and the player have won. The score of the winner increases by one point. If there is a tie, the score does not increase." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "SLhPrL_J_d_F" - }, - "source": [ - "### z should be the outcome of the 'winner' function\n", - "def roundin(z):\n", - " result = {0:'Tie!',1:'I win.',2:'You win.'}\n", - " print('You chose ' + player)\n", - " print('I chose ' + quick_thumb)\n", - " print(result[z])" - ], - "execution_count": 18, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZwuFjPhC_d_F" - }, - "source": [ - "#### 10. Now it's time to code the execution of the game using the functions and variables you defined above. \n", - "\n", - "First, create a loop structure that repeats while no player reaches the minimum score necessary to win and the number of rounds is less than the maximum number of rounds to play in a game. \n", - "\n", - "Inside the loop, use the functions and variables above to create the execution of a round: ask for the player's choice, generate the random choice of the computer, show the round results, update the scores, etc. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "EtvtiYq9_d_F", - "outputId": "cacb87b2-f8fb-49e4-e1cb-4f43b5b3e35f" - }, - "source": [ - "rounds_done = 0\n", - "while rounds_done < n_rounds and cpu_score < rounds_to_win and player_score < rounds_to_win:\n", - " player = shand(gestures)\n", - " quick_thumb = T800(gestures)\n", - " outcome = winner(joy)\n", - " roundin(outcome)\n", - " rounds_done += 1\n", - " if outcome == 1:\n", - " cpu_score += 1\n", - " elif outcome == 2:\n", - " player_score += 1\n" - ], - "execution_count": 19, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Please choose wisely: ['rock', 'paper', 'scissors'] >>> rock\n", - "You chose rock\n", - "I chose rock\n", - "Tie!\n", - "Please choose wisely: ['rock', 'paper', 'scissors'] >>> paper\n", - "You chose paper\n", - "I chose scissors\n", - "I win.\n", - "Please choose wisely: ['rock', 'paper', 'scissors'] >>> rock\n", - "You chose rock\n", - "I chose rock\n", - "Tie!\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "9J-rI54X_d_F" - }, - "source": [ - "#### 11. Print the winner of the game based on who won more rounds.\n", - "Remember that the game might be tied. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "5ak5tH58_d_F", - "outputId": "dd91d7d9-3b72-45fc-ad99-6ad8516897e0" - }, - "source": [ - "if player_score >= cpu_score:\n", - " print(\"You win. \\nThor: 'Loki, my mind is going.'\")\n", - "elif cpu_score >= player_score:\n", - " print(\"CPU wins! \\nThe Instructor: 'So did the man went down with his choice.'\")\n", - "else:\n", - " print(\"Tie.\")" - ], - "execution_count": 22, - "outputs": [ - { - "output_type": "stream", - "text": [ - "CPU wins! \n", - "The Instructor: 'So did the man went down with his choice.'\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "vYLAdCkq_d_F" - }, - "source": [ - "# Bonus: Rock, Paper, Scissors, Lizard & Spock\n", - "![](images/rpsls.jpg)\n", - "\n", - "In this challenge, you need to improve the previous game by adding two new options. To know more about the rules of the improved version of rock, paper, scissors, check this [link](http://www.samkass.com/theories/RPSSL.html). \n", - "\n", - "In addition, you will also need to improve how the game interacts with the player: the number of rounds to play, which must be an odd number, will be requested to the user until a valid number is entered. Define a new function to make that request.\n", - "\n", - "**Hint**: Try to reuse the code that you already coded in the previous challenge. If your code is efficient, this bonus will only consist of simple modifications to the original game." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "6Fv-Y4kS_d_G", - "outputId": "90f6b59c-bef5-4ad5-a4d9-fef8f5c8f421" - }, - "source": [ - "gestures2 = ['rock','paper','scissors','lizard','spock']\n", - "joy2 = {'rock':['scissors','lizard'], 'paper':['rock','spock'], 'scissors':['paper','lizard'], 'lizard':['spock','paper'],'spock':['rock','scissors']}\n", - "cpu_score = 0\n", - "player_score = 0\n", - "rounds_done = 0\n", - "while rounds_done < n_rounds and cpu_score < rounds_to_win and player_score < rounds_to_win:\n", - " player = shand(gestures2)\n", - " quick_thumb = T800(gestures2)\n", - " outcome = winner(joy2)\n", - " roundin(outcome)\n", - " rounds_done += 1\n", - " if outcome == 1:\n", - " cpu_score += 1\n", - " elif outcome == 2:\n", - " player_score += 1\n", - "if player_score >= cpu_score:\n", - " print(\"You won... \\nThor: 'Loki, my mind is going crazy.'\")\n", - "elif cpu_score >= player_score:\n", - " print(\"CPU wins! \\nThe Instructor: 'So did the man went down with his choice.'\")\n", - "else:\n", - " print(\"Tie.\")" - ], - "execution_count": 25, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> rock\n", - "You chose rock\n", - "I chose lizard\n", - "You win.\n", - "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> scissors\n", - "You chose scissors\n", - "I chose rock\n", - "I win.\n", - "Please choose wisely: ['rock', 'paper', 'scissors', 'lizard', 'spock'] >>> lizard\n", - "You chose lizard\n", - "I chose spock\n", - "You win.\n", - "You won... \n", - "Thor: 'Loki, my mind is going crazy.'\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From a1267513fdc3e098e6b341cd6140f37187e9752e Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:48:29 +0200 Subject: [PATCH 10/14] Delete robin_hood.ipynb --- robin_hood.ipynb | 279 ----------------------------------------------- 1 file changed, 279 deletions(-) delete mode 100644 robin_hood.ipynb diff --git a/robin_hood.ipynb b/robin_hood.ipynb deleted file mode 100644 index 1683b8aaf..000000000 --- a/robin_hood.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "robin-hood.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "5Iylrv5g3OmC" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "0OpeHAHt3OmF" - }, - "source": [ - "# Robin Hood\n", - "Robin Hood has entered a competition to win the archery contest in Sherwood. With his bow and arrows, he needs to shoot on a target and try to hit as close as possible to the center.\n", - "\n", - "![](images/arrows.jpg)\n", - "\n", - "## Context\n", - "In this challenge, the landing position of arrows shot by archers in the competition will be represented using 2-dimensional coordinates. \n", - "\n", - "In the 2-dimensional space, a point can be defined by a pair of values that correspond to the horizontal coordinate (x) and the vertical coordinate (y). For example, in our case, an arrow that hits the center of the archery target will land in position (0, 0) on the coordinate axes. \n", - "\n", - "The space can be divided into 4 zones (quadrants): Q1, Q2, Q3, Q4. If a point is in Q1, both its x coordinate and y coordinate are positive. Any point with a null x or y coordinate is considered to not belong to any quadrant. \n", - "\n", - "If you want to know more about the cartesian coordinate system, you can check this [link](https://en.wikipedia.org/wiki/Cartesian_coordinate_system). \n", - "\n", - "## Tools\n", - "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", - "* Data structures: **lists, sets, tuples**\n", - "* Conditional statements: **if-elif-else**\n", - "* Loop: **while/for**\n", - "* Minimum (optional sorting)\n", - "\n", - "## Tasks\n", - "Robin Hood has hit the following points:" - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "fRvR5qj03OmG" - }, - "source": [ - "points = [(4, 5), (-0, 2), (4, 7), (1, -3), (3, -2), (4, 5), (3, 2), (5, 7), (-5, 7), (2, 2), (-4, 5), (0, -2),\n", - " (-4, 7), (-1, 3), (-3, 2), (-4, -5), (-3, 2), (5, 7), (5, 7), (2, 2), (9, 9), (-8, -9)]" - ], - "execution_count": 3, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_YKX2NPm3OmG" - }, - "source": [ - "#### 1. Robin Hood is famous for hitting an arrow with another arrow. Find the coordinates of the points where an arrow hits another arrow." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "D0huQlsc3OmH", - "outputId": "5b668afe-8ac6-4fb2-9607-578abd5b489c" - }, - "source": [ - "bullseye = []\n", - "for i in range(len(points)):\n", - " if points[i] in points[i+1:]:\n", - " bullseye.append(points[i])\n", - "print(set(bullseye))" - ], - "execution_count": 4, - "outputs": [ - { - "output_type": "stream", - "text": [ - "{(4, 5), (5, 7), (-3, 2), (2, 2)}\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "4jjRMDPL3OmH" - }, - "source": [ - "#### 2. Calculate how many arrows have fallen in each quadrant. \n", - "**Note**: the arrows that fall in the axis (x=0 or y=0) don't belong to any quadrant." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "r1BOSax-3OmH", - "outputId": "3ad96f41-8235-4bca-fa41-3abfc86fd8d3" - }, - "source": [ - "q1 = []\n", - "q2 = []\n", - "q3 = []\n", - "q4 = []\n", - "count = 0\n", - "while count < len(points):\n", - " for hey,you in points[count:count+1]:\n", - " if hey > 0 and you > 0:\n", - " q1.append(points[count])\n", - " elif hey > 0 and you < 0:\n", - " q4.append(points[count])\n", - " elif hey < 0 and you > 0:\n", - " q2.append(points[count])\n", - " elif hey < 0 and you < 0:\n", - " q3.append(points[count])\n", - " count += 1\n", - "solution = \"There is a total of \" + str(len(q1)) + \" arrows in quadrant 1, \" + str(len(q2)) + \" arrows in quadrant 2, \" + str(len(q3)) + \" arrows in quadrant 3 and \" + str(len(q4)) + \" arrows in quadrant 4.\"\n", - "print(solution)\n", - "print(points[7:].index((5,7)))" - ], - "execution_count": 5, - "outputs": [ - { - "output_type": "stream", - "text": [ - "There is a total of 10 arrows in quadrant 1, 6 arrows in quadrant 2, 2 arrows in quadrant 3 and 2 arrows in quadrant 4.\n", - "0\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "uhl9zx323OmI" - }, - "source": [ - "#### 3. Find the point closest to the center. Calculate its distance to the center. \n", - "Take into account that there might be more than one point at the minimum distance to the center.\n", - "\n", - "**Hint**: Use the Euclidean distance. You can find more information about it [here](https://en.wikipedia.org/wiki/Euclidean_distance). \n", - "**Hint**: Defining a function that calculates the distance to the center can help." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "7xcnOUB03OmI", - "outputId": "9ce0dc48-2186-4a92-cee8-e051fe4ef339" - }, - "source": [ - "##defining distance from center\n", - "\n", - "import math\n", - "def ramayana(shot):\n", - " hey = shot[0]\n", - " you = shot[1]\n", - " distance = math.sqrt(hey**2 + you**2)\n", - " return distance\n", - "\n", - "##creating list of distances\n", - "\n", - "distances = []\n", - "for i in points:\n", - " distances.append(round(ramayana(i), 2))\n", - "print(distances)\n", - "##creating list of closest points\n", - "\n", - "counter = 0\n", - "marksman = []\n", - "for i in distances:\n", - " if i == min(distances):\n", - " marksman.append(points[counter])\n", - " counter += 1 \n", - "\n", - "##printing solution\n", - "\n", - "print(\"The closest point(s) to the center is(are):\", marksman)\n", - "print(\"The distance of the closest point to the center is:\", min(distances))" - ], - "execution_count": 6, - "outputs": [ - { - "output_type": "stream", - "text": [ - "[6.4, 2.0, 8.06, 3.16, 3.61, 6.4, 3.61, 8.6, 8.6, 2.83, 6.4, 2.0, 8.06, 3.16, 3.61, 6.4, 3.61, 8.6, 8.6, 2.83, 12.73, 12.04]\n", - "The closest point(s) to the center is(are): [(0, 2), (0, -2)]\n", - "The distance of the closest point to the center is: 2.0\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "hXzKW4h93OmI" - }, - "source": [ - "#### 4. If the archery target has a radius of 9, calculate the number of arrows that won't hit the target. \n", - "**Hint**: Use the function created in step 3. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "EPcKF9j63OmJ", - "outputId": "d7282f6b-7d57-4953-80d2-31d6dd618306" - }, - "source": [ - "radius = 9\n", - "print(sum(1 for i in distances if i > radius), \"arrows didn't meet the target.\")" - ], - "execution_count": 7, - "outputs": [ - { - "output_type": "stream", - "text": [ - "2 arrows didn't meet the target.\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From b06989b42eb728d3e2e330f4b49adbeaf54a6940 Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:48:58 +0200 Subject: [PATCH 11/14] Delete duel_of_sorcerers.ipynb --- duel_of_sorcerers.ipynb | 410 ---------------------------------------- 1 file changed, 410 deletions(-) delete mode 100644 duel_of_sorcerers.ipynb diff --git a/duel_of_sorcerers.ipynb b/duel_of_sorcerers.ipynb deleted file mode 100644 index 54d4c949c..000000000 --- a/duel_of_sorcerers.ipynb +++ /dev/null @@ -1,410 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "duel-of-sorcerers.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "FvJVj3ZxpeQH" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "i4yCepjipeQJ" - }, - "source": [ - "# Duel of Sorcerers\n", - "You are witnessing an epic battle between two powerful sorcerers: Gandalf and Saruman. Each sorcerer has 10 spells of variable power in their mind and they are going to throw them one after the other. The winner of the duel will be the one who wins more of those clashes between spells. Spells are represented as a list of 10 integers whose value equals the power of the spell.\n", - "```\n", - "gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22]\n", - "saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]\n", - "```\n", - "For example:\n", - "- The first clash is won by Saruman: 10 against 23.\n", - "- The second clash is won by Saruman: 11 against 66.\n", - "- ...\n", - "\n", - "You will create two variables, one for each sorcerer, where the sum of clashes won will be stored. Depending on which variable is greater at the end of the duel, you will show one of the following three results on the screen:\n", - "* Gandalf wins\n", - "* Saruman wins\n", - "* Tie\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "dQva1x2bpeQK" - }, - "source": [ - "## Tools\n", - "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", - "\n", - "1. Data structures: **lists, dictionaries**\n", - "2. Loop: **for loop**\n", - "3. Conditional statements: **if-elif-else**\n", - "4. Functions: **range(), len(), print()**\n", - "\n", - "## Tasks\n", - "\n", - "#### 1. Create two variables called `gandalf` and `saruman` and assign them the spell power lists. Create a variable called `spells` to store the number of spells that the sorcerers cast. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "z5pDvW-GpeQL" - }, - "source": [ - "gandalf = [10, 11, 13, 30, 22, 11, 10, 33, 22, 22]\n", - "saruman = [23, 66, 12, 43, 12, 10, 44, 23, 12, 17]\n", - "spells = len(gandalf)" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ZkjpXzbvpeQL" - }, - "source": [ - "#### 2. Create two variables called `gandalf_wins` and `saruman_wins`. Set both of them to 0. \n", - "You will use these variables to count the number of clashes each sorcerer wins. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "Gjq-r4OnpeQL" - }, - "source": [ - "gandalf_wins = 0\n", - "saruman_wins = 0" - ], - "execution_count": 3, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "cxDd5RSSpeQM" - }, - "source": [ - "#### 3. Using the lists of spells of both sorcerers, update variables `gandalf_wins` and `saruman_wins` to count the number of times each sorcerer wins a clash. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "SOEIuF0npeQM" - }, - "source": [ - "for i in range(spells):\n", - " if gandalf[i] > saruman[i]:\n", - " gandalf_wins += 1\n", - " elif gandalf[i] < saruman[i]:\n", - " saruman_wins += 1" - ], - "execution_count": 5, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_jmaIx-XpeQM" - }, - "source": [ - "#### 4. Who won the battle?\n", - "Print `Gandalf wins`, `Saruman wins` or `Tie` depending on the result. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "Ie202WDvpeQN", - "outputId": "478c49b7-7699-4547-996d-832effa06312" - }, - "source": [ - "if gandalf_wins > saruman_wins:\n", - " print(\"Gandalf wins\")\n", - "elif gandalf_wins < saruman_wins:\n", - " print(\"Saruman wins\")\n", - "else: \n", - " print(\"Tie\")" - ], - "execution_count": 8, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Gandalf wins\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "QAPHT4KbpeQN" - }, - "source": [ - "## Bonus\n", - "\n", - "In this bonus challenge, you'll need to check the winner of the battle but this time, a sorcerer wins if he succeeds in winning 3 spell clashes in a row.\n", - "\n", - "Also, the spells now have a name and there is a dictionary that associates that name to a power.\n", - "\n", - "```\n", - "POWER = {\n", - " 'Fireball': 50, \n", - " 'Lightning bolt': 40, \n", - " 'Magic arrow': 10, \n", - " 'Black Tentacles': 25, \n", - " 'Contagion': 45\n", - "}\n", - "\n", - "gandalf = ['Fireball', 'Lightning bolt', 'Lightning bolt', 'Magic arrow', 'Fireball', \n", - " 'Magic arrow', 'Lightning bolt', 'Fireball', 'Fireball', 'Fireball']\n", - "saruman = ['Contagion', 'Contagion', 'Black Tentacles', 'Fireball', 'Black Tentacles', \n", - " 'Lightning bolt', 'Magic arrow', 'Contagion', 'Magic arrow', 'Magic arrow']\n", - "```\n", - "\n", - "#### 1. Create variables `POWER`, `gandalf` and `saruman` as seen above. Create a variable called `spells` to store the number of spells that the sorcerers cast. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "2jc2H9ExpeQN" - }, - "source": [ - "POWER = {\n", - " 'Fireball': 50, \n", - " 'Lightning bolt': 40, \n", - " 'Magic arrow': 10, \n", - " 'Black Tentacles': 25, \n", - " 'Contagion': 45\n", - "}\n", - "\n", - "gandalf = ['Fireball', 'Lightning bolt', 'Lightning bolt', 'Magic arrow', 'Fireball', \n", - " 'Magic arrow', 'Lightning bolt', 'Fireball', 'Fireball', 'Fireball']\n", - "saruman = ['Contagion', 'Contagion', 'Black Tentacles', 'Fireball', 'Black Tentacles', \n", - " 'Lightning bolt', 'Magic arrow', 'Contagion', 'Magic arrow', 'Magic arrow']\n", - "spells = 0" - ], - "execution_count": 10, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "GgzmoM74peQO" - }, - "source": [ - "#### 2. Create two variables called `gandalf_wins` and `saruman_wins`. Set both of them to 0. " - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "WX160BXqpeQO" - }, - "source": [ - "gandalf_wins = 0\n", - "saruman_wins = 0" - ], - "execution_count": 11, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "W_13AxdFpeQO" - }, - "source": [ - "#### 3. Create two variables called `gandalf_power` and `saruman_power` to store the list of spell powers of each sorcerer." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "WT66_UDIpeQO" - }, - "source": [ - "gandalf_power = []\n", - "for i in gandalf:\n", - " gandalf_power.append(POWER[i])\n", - "saruman_power = []\n", - "for i in saruman:\n", - " saruman_power.append(POWER[i])" - ], - "execution_count": 13, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "zV-muqY-peQP" - }, - "source": [ - "#### 4. The battle starts! Using the variables you've created above, code the execution of spell clashes. Remember that a sorcerer wins if he succeeds in winning 3 spell clashes in a row. \n", - "If a clash ends up in a tie, the counter of wins in a row is not restarted to 0. Remember to print who is the winner of the battle. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "donBaJl9peQP", - "outputId": "8abea79a-eb11-4bc3-bc25-7164e0cc235c" - }, - "source": [ - "while gandalf_wins != 3 and saruman_wins != 3: \n", - " if gandalf_power[spells] > saruman_power[spells]:\n", - " gandalf_wins += 1\n", - " while gandalf_wins in [1,2]:\n", - " spells += 1\n", - " if gandalf_power[spells] > saruman_power[spells]:\n", - " gandalf_wins += 1\n", - " else:\n", - " gandalf_wins = 0\n", - " elif gandalf_power[spells] < saruman_power[spells]:\n", - " saruman_wins += 1\n", - " while saruman_wins in [1,2]:\n", - " spells += 1\n", - " if gandalf_power[spells] < saruman_power[spells]:\n", - " saruman_wins += 1\n", - " else:\n", - " saruman_wins = 0 \n", - "\n", - "if gandalf_wins > saruman_wins:\n", - " print(\"Gandalf wins\")\n", - "else:\n", - " print(\"Saruman wins\")" - ], - "execution_count": 14, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Gandalf wins\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Af-3InlipeQP" - }, - "source": [ - "#### 5. Find the average spell power of Gandalf and Saruman. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "GL97Iv2npeQP", - "outputId": "0c164e33-de6b-4c93-dfa0-b068a1f594c5" - }, - "source": [ - "from statistics import mean\n", - "print(f\"The average power of Gandalf is {round(mean(gandalf_power), 2)}, and Saruman's average power is {round(mean(saruman_power), 2)}\")" - ], - "execution_count": 16, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The average power of Gandalf is 39, and Saruman's average power is 30.5\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "6FB5Oc1PpeQP" - }, - "source": [ - "#### 6. Find the standard deviation of the spell power of Gandalf and Saruman. " - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "eEEpswIupeQP", - "outputId": "35e8d48c-8c61-4cb5-d13b-661adc16d861" - }, - "source": [ - "from statistics import stdev\n", - "print(f\"The standard deviation of powers of Gandalf's power is {round(stdev(gandalf_power), 2)}, while Saruman's is {round(stdev(saruman_power), 2)}\")\n", - "textest = 'urray'\n" - ], - "execution_count": 18, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The standard deviation of powers of Gandalf's power is 15.95, while Saruman's is 16.41\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From 56280e64fb70527e1bbb1d17e392a90a1d24536f Mon Sep 17 00:00:00 2001 From: Ronaldo Licaj <81906525+ronlicaj@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:49:07 +0200 Subject: [PATCH 12/14] Delete bus.ipynb --- bus.ipynb | 216 ------------------------------------------------------ 1 file changed, 216 deletions(-) delete mode 100644 bus.ipynb diff --git a/bus.ipynb b/bus.ipynb deleted file mode 100644 index 6d08f4186..000000000 --- a/bus.ipynb +++ /dev/null @@ -1,216 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.7.2" - }, - "colab": { - "name": "bus.ipynb", - "provenance": [], - "include_colab_link": true - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "z_YHfQiB1XGF" - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Q_SSvLI31XGI" - }, - "source": [ - "# Bus\n", - "\n", - "This bus has a passenger entry and exit control system to monitor the number of occupants it carries and thus detect when there are too many.\n", - "\n", - "At each stop, the entry and exit of passengers is represented by a tuple consisting of two integer numbers.\n", - "```\n", - "bus_stop = (in, out)\n", - "```\n", - "The succession of stops is represented by a list of these tuples.\n", - "```\n", - "stops = [(in1, out1), (in2, out2), (in3, out3), (in4, out4)]\n", - "```\n", - "\n", - "## Tools\n", - "You don't necessarily need to use all the tools. Maybe you opt to use some of them or completely different ones, they are given to help you shape the exercise. Programming exercises can be solved in many different ways.\n", - "* Data structures: **lists, tuples**\n", - "* Loop: **while/for loops**\n", - "* Functions: **min, max, len**\n", - "\n", - "## Tasks" - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "lgNOzt3C1XGI" - }, - "source": [ - "# Variables\n", - "stops = [(10, 0), (4, 1), (3, 5), (3, 4), (5, 1), (1, 5), (5, 8), (4, 6), (2, 3)]\n", - "movement = []\n", - "occupation = []" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "rLzsRyFa1XGJ" - }, - "source": [ - "#### 1. Calculate the number of stops." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "C1qp08Vs1XGJ", - "outputId": "10cc9799-3dfe-4341-a491-f9754a8f1f91" - }, - "source": [ - "total_stops = len(stops)\n", - "print(\"The total number of bus stops is\", total_stops)" - ], - "execution_count": 2, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The total number of bus stops is 9\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Kpvvz1w01XGK" - }, - "source": [ - "#### 2. Assign to a variable a list whose elements are the number of passengers at each stop (in-out).\n", - "Each item depends on the previous item in the list + in - out." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "X5VMevZr1XGK" - }, - "source": [ - "for up,down in stops:\n", - " movement.append(up - down)\n", - "\n", - "for i in range(total_stops):\n", - " occupation.append(sum(movement[0:i+1]))" - ], - "execution_count": 5, - "outputs": [] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "DQZrYZPd1XGK" - }, - "source": [ - "#### 3. Find the maximum occupation of the bus." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "ueI7jmx01XGL", - "outputId": "2e938b3f-ccf2-4d20-9fbd-4dbf7b4f5b07" - }, - "source": [ - "print(\"The maximum occupation in the bus is\", max(occupation))" - ], - "execution_count": 6, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The maximum occupation in the bus is 14\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "Q2PgsIxM1XGL" - }, - "source": [ - "#### 4. Calculate the average occupation. And the standard deviation." - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "0aVwHdMS1XGL", - "outputId": "6b16b77a-1198-46ec-9eea-8a9b8ceeca6b" - }, - "source": [ - "print(\"The average occupation is\", round((sum(occupation)/total_stops), 2))\n", - "import statistics\n", - "print(\"The standard deviation of the occupation is\", round(statistics.stdev(occupation), 2))" - ], - "execution_count": 7, - "outputs": [ - { - "output_type": "stream", - "text": [ - "The average occupation is 28.0\n", - "The standard deviation of the occupation is 3.26\n" - ], - "name": "stdout" - } - ] - } - ] -} \ No newline at end of file From ab010c2523f9037c3e0ce393801a281f86a90ff7 Mon Sep 17 00:00:00 2001 From: ronaldo licaj Date: Wed, 28 Jul 2021 18:02:18 +0200 Subject: [PATCH 13/14] uploaded solutions --- 2.-Statistics/1..png | Bin 0 -> 76764 bytes 2.-Statistics/10..png | Bin 0 -> 129110 bytes 2.-Statistics/11..png | Bin 0 -> 158626 bytes 2.-Statistics/12..png | Bin 0 -> 124942 bytes 2.-Statistics/13..png | Bin 0 -> 124291 bytes 2.-Statistics/14..png | Bin 0 -> 135633 bytes 2.-Statistics/15..png | Bin 0 -> 145644 bytes 2.-Statistics/2..png | Bin 0 -> 113968 bytes 2.-Statistics/3..png | Bin 0 -> 137352 bytes 2.-Statistics/4..png | Bin 0 -> 141728 bytes 2.-Statistics/5..png | Bin 0 -> 165563 bytes 2.-Statistics/6..png | Bin 0 -> 120617 bytes 2.-Statistics/7..png | Bin 0 -> 122293 bytes 2.-Statistics/8..png | Bin 0 -> 144281 bytes 2.-Statistics/9..png | Bin 0 -> 122862 bytes 15 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 2.-Statistics/1..png create mode 100644 2.-Statistics/10..png create mode 100644 2.-Statistics/11..png create mode 100644 2.-Statistics/12..png create mode 100644 2.-Statistics/13..png create mode 100644 2.-Statistics/14..png create mode 100644 2.-Statistics/15..png create mode 100644 2.-Statistics/2..png create mode 100644 2.-Statistics/3..png create mode 100644 2.-Statistics/4..png create mode 100644 2.-Statistics/5..png create mode 100644 2.-Statistics/6..png create mode 100644 2.-Statistics/7..png create mode 100644 2.-Statistics/8..png create mode 100644 2.-Statistics/9..png diff --git a/2.-Statistics/1..png b/2.-Statistics/1..png new file mode 100644 index 0000000000000000000000000000000000000000..acbe4ccbaeec88a35e0a0970cbd5a36055761e3a GIT binary patch literal 76764 zcmdSBhgZ{E)GZoNL_tLb3n)dZG?6CKQIsN5Ly>+|Y7kH$Afa0T3(|WDNDoawK)Q-Z z?+J(qsPxc74fU>g&b{Az*YM(Z(DfeQ=>oa zvzNTjTBKL zO@3dtX@Q}J45p8`XURf&Quw9Be2a?dzc1teFZoi*+o3l@ePyy^=!1PvMhT3 zN14~gg1p!I93juh8S6%Q^#nO)jGnFfxE9Uf?Sj0hHFQlk3G%#1E`9!;s@gBR$u zTAjG8{J1q0@#i?@Ez)%x0v&&Rm>H?9X7i)G!zHvBN9?`Iqn%V77CH!;6YL3B9e<=L z)5=d$_H^l1%P+IQY0UfMh~g0HOa9lwVq*Gpk$m!a%6Cs3unO+%`c3tfhAtIx-@GqN zGuM~$_o8Zth!<$-IM#LH4f|LmA2y4O!e{x%@id@2;qSlw{revu?9*ut;pK??5l4Tl zEwLi*pMpm$&ND8xF8?6Wx=gUFw%X}jzF=GCkH>sGE-VlFQma?h; z-E~hf{{dz4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