From 88d6dbd025980762e51c6d8cf0ff2e3fc50dde97 Mon Sep 17 00:00:00 2001
From: Robert Lanzafame <R.C.Lanzafame@tudelft.nl>
Date: Wed, 4 Sep 2024 09:47:03 +0200
Subject: [PATCH] PA

---
 content/week_1_1/PA_1_1_Catch_Them_All.ipynb | 177 +++++++++++++++----
 content/week_1_1/catchme.py                  |  53 +-----
 2 files changed, 147 insertions(+), 83 deletions(-)

diff --git a/content/week_1_1/PA_1_1_Catch_Them_All.ipynb b/content/week_1_1/PA_1_1_Catch_Them_All.ipynb
index cddbd9c9..30d40708 100644
--- a/content/week_1_1/PA_1_1_Catch_Them_All.ipynb
+++ b/content/week_1_1/PA_1_1_Catch_Them_All.ipynb
@@ -63,31 +63,15 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": null,
    "id": "46016f72",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "If you connected to an environment with Python, this sentence will be printed below.\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "print('If you connected to an environment with Python,'\n",
     "      ' this sentence will be printed below.')"
    ]
   },
-  {
-   "cell_type": "markdown",
-   "id": "2cdac622",
-   "metadata": {},
-   "source": [
-    "## Task 1: What is a dictionary?"
-   ]
-  },
   {
    "cell_type": "markdown",
    "id": "6c4216c5",
@@ -103,9 +87,123 @@
     "4. It uses a syntax with square brackets to get the _value_ associated with a given _key_.\n"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "5e5038e5",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 1.1:</b>   \n",
+    "run the cell below to see what happens when you define a dictionary and then print it.\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "af0346a6",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "test_dictionary = {'key1': 'value1', 'key2': 'value2'}\n",
+    "print(test_dictionary)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "1ed9db40",
+   "metadata": {},
+   "source": [
+    "To access the value, you can use the following syntax:\n",
+    "\n",
+    "```\n",
+    "test_dictionary['KEY']\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "f5905dd1",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 1.2:</b>   \n",
+    "run the cell below to access the value for <code>key2</code>.\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": null,
+   "id": "33878a0a",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "test_dictionary['key2']"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "d4cc0df0",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 1.3:</b>   \n",
+    "run the cell below to access add a key-value pair for <code>key3</code>.\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "cfdbcfbf",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "test_dictionary['key3'] = 'value3'\n",
+    "print(test_dictionary['key3'])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "948fe1f6",
+   "metadata": {},
+   "source": [
+    "That's it! Now you are ready to start using a dictionary with \"real\" data!"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "15fddde1",
+   "metadata": {},
+   "source": [
+    "## Part 2: Using a dictionary with \"real\" data\n",
+    "\n",
+    "In this part we illustrate how easy it is to load text-based files into notebooks, then operate on them with Python code."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "c44dc7e4",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 2.1:</b>   \n",
+    "open up the contents of the file <code>catchme.py</code> and <b>read</b> it. This file defines a dictionary called <code>data</code>, which we will import into our notebook and access the content by running the cell below.\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
    "id": "a0e30b2c",
    "metadata": {},
    "outputs": [],
@@ -114,22 +212,35 @@
     "data = catchme.data"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "583d6654",
+   "metadata": {},
+   "source": [
+    "<div style=\"background-color:#AABAB2; color: black; vertical-align: middle; padding:15px; margin: 10px; border-radius: 10px; width: 95%\">\n",
+    "<p>\n",
+    "<b>Task 2.2:</b>   \n",
+    "If the cell above ran without error, you should be use the dictionary <code>data</code> in exactly the same way as <code>test_dictionary</code>. To check whether you understand how a dictionary works, see if you can print the <em>value</em> for the <em>species</em> of this \"thing\" in the dictionary.\n",
+    "</p>\n",
+    "</div>"
+   ]
+  },
   {
    "cell_type": "code",
-   "execution_count": 2,
-   "id": "5361a3a2",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "{'Bulbasaur': {'type': 'Grass/Poison', 'species': 'Seed Pokemon', 'height': 0.7, 'weight': 6.9, 'abilities': ['Overgrow', 'Chlorophyll'], 'base_stats': {'hp': 45, 'attack': 49, 'defense': 49, 'speed': 45}, 'evolves_to': 'Ivysaur', 'move_set': ['Growl', 'Tackle', 'Vine Whip']}, 'Charmander': {'type': 'Fire', 'species': 'Lizard Pokemon', 'height': 0.6, 'weight': 8.5, 'abilities': ['Blaze', 'Solar Power'], 'base_stats': {'hp': 39, 'attack': 52, 'defense': 43, 'speed': 65}, 'evolves_to': 'Charmeleon', 'move_set': ['Growl', 'Scratch', 'Ember']}, 'Squirtle': {'type': 'Water', 'species': 'Tiny Turtle Pokemon', 'height': 0.5, 'weight': 9.0, 'abilities': ['Torrent', 'Rain Dish'], 'base_stats': {'hp': 44, 'attack': 48, 'defense': 65, 'speed': 43}, 'evolves_to': 'Wartortle', 'move_set': ['Tackle', 'Tail Whip', 'Water Gun']}, 'Pikachu': {'type': 'Electric', 'species': 'Mouse Pokemon', 'height': 0.4, 'weight': 6.0, 'abilities': ['Static', 'Lightning Rod'], 'base_stats': {'hp': 35, 'attack': 55, 'defense': 40, 'speed': 90}, 'evolves_to': 'Raichu', 'move_set': ['Growl', 'Quick Attack', 'Thunder Shock']}}\n"
-     ]
-    }
-   ],
-   "source": [
-    "print(data)"
+   "execution_count": null,
+   "id": "1dd07209",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "YOUR_CODE_HERE"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "a1f56c52",
+   "metadata": {},
+   "source": [
+    "**That's it!** This was a short PA...later ones will be longer."
    ]
   },
   {
diff --git a/content/week_1_1/catchme.py b/content/week_1_1/catchme.py
index b7989d30..2fcd3d95 100644
--- a/content/week_1_1/catchme.py
+++ b/content/week_1_1/catchme.py
@@ -1,5 +1,4 @@
-data = {
-    'Bulbasaur': {
+data = {'name': 'Bulbasaur',
         'type': 'Grass/Poison',
         'species': 'Seed Pokemon',
         'height': 0.7,
@@ -12,51 +11,5 @@ data = {
             'speed': 45
         },
         'evolves_to': 'Ivysaur',
-        'move_set': ['Growl', 'Tackle', 'Vine Whip'],
-    },
-    'Charmander': {
-        'type': 'Fire',
-        'species': 'Lizard Pokemon',
-        'height': 0.6,
-        'weight': 8.5,
-        'abilities': ['Blaze', 'Solar Power'],
-        'base_stats': {
-            'hp': 39,
-            'attack': 52,
-            'defense': 43,
-            'speed': 65
-        },
-        'evolves_to': 'Charmeleon',
-        'move_set': ['Growl', 'Scratch', 'Ember'],
-    },
-    'Squirtle': {
-        'type': 'Water',
-        'species': 'Tiny Turtle Pokemon',
-        'height': 0.5,
-        'weight': 9.0,
-        'abilities': ['Torrent', 'Rain Dish'],
-        'base_stats': {
-            'hp': 44,
-            'attack': 48,
-            'defense': 65,
-            'speed': 43
-        },
-        'evolves_to': 'Wartortle',
-        'move_set': ['Tackle', 'Tail Whip', 'Water Gun'],
-    },
-    'Pikachu': {
-        'type': 'Electric',
-        'species': 'Mouse Pokemon',
-        'height': 0.4,
-        'weight': 6.0,
-        'abilities': ['Static', 'Lightning Rod'],
-        'base_stats': {
-            'hp': 35,
-            'attack': 55,
-            'defense': 40,
-            'speed': 90
-        },
-        'evolves_to': 'Raichu',
-        'move_set': ['Growl', 'Quick Attack', 'Thunder Shock'],
-    }
-}
\ No newline at end of file
+        'move_set': ['Growl', 'Tackle', 'Vine Whip']
+}   
\ No newline at end of file
-- 
GitLab