From cffba74ba2350a5c9439a2516ca755be4b13ea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Wed, 15 Apr 2026 16:47:10 +0200 Subject: [PATCH 1/5] Update lab-python-data-structures.ipynb test update --- lab-python-data-structures.ipynb | 89 +++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 8ba652c..a4b2c99 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -61,7 +61,18 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here" + "sutudents_grades = []\n", + "for i in range(5):\n", + " grades_input = float(input(\"Enter the grade of each student: \"))\n", + " sutudents_grades.append(grades_input)\n", + "\n", + "sum_grades = sum(sutudents_grades)\n", + "students_selection = sutudents_grades[0:5:2]\n", + "students_selection.sort()\n", + "\n", + "print (f\"The sum of the grades is: {sum_grades}\")\n", + "print (f\"Sorted list of the performance of {len(students_selection)} students: {students_selection}\")\n", + "print (\"The number of occurrences of the score '5' is:\", sutudents_grades.count(5))" ] }, { @@ -99,9 +110,24 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here" + "fruits = (\"banana\", \"orange\", \"pineapple\", \"watermelon\", \"grape\")\n", + "print(fruits[0:5])\n", + "fruits = (\"banana\", \"kiwi\", \"pineapple\", \"watermelon\", \"grape\")\n", + "print(fruits)\n", + "fruits_1 = (\"apple\",\"melon\")\n", + "new_fruits = fruits + fruits_1\n", + "print(new_fruits)\n", + "fruits_2 = new_fruits[0:3]\n", + "fruits_3 = new_fruits[3:6]\n", + "mega_fruits = fruits + fruits_2 + fruits_3\n", + "print(mega_fruits, len(mega_fruits))\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -167,7 +193,14 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here" + "set_poem = set(poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").replace(\"\\n\",\" \").lower().split(\" \"))\n", + "set_new_poem = set(new_poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"'\",\"\").replace(\"\\n\",\" \").lower().split(\" \")) \n", + "unique_words_poem = set_poem - set_new_poem\n", + "unique_words_new_poem = set_new_poem - set_poem\n", + "print(unique_words_poem)\n", + "print(unique_words_new_poem)\n", + "unique_words = set_poem & set_new_poem\n", + "print(sorted(unique_words))" ] }, { @@ -193,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -206,7 +239,8 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here" + "grades[\"Bob\"][\"Philosophy\"]=100\n", + "print(grades)" ] }, { @@ -239,14 +273,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Physics': 75, 'Math': 85, 'Chemistry': 60, 'Philosophy': 90}\n" + ] + } + ], "source": [ "keys = ['Physics', 'Math', 'Chemistry', 'Philosophy']\n", "values = [75, 85, 60,90]\n", "\n", - "# Your code here" + "grades = dict(zip(keys,values))\n", + "\n", + "\n", + "print (grades)" ] }, { @@ -275,17 +320,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Chemistry'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here" + "min(grades, key=grades.get)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -299,7 +362,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.4" } }, "nbformat": 4, From 3c68eafc248ec54a77cc8429c6d24aa58fdbcc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Wed, 15 Apr 2026 17:35:03 +0200 Subject: [PATCH 2/5] Update lab-python-data-structures.ipynb subo cambios --- lab-python-data-structures.ipynb | 114 ++++++++++++++++++------------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index a4b2c99..d9c9987 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -57,22 +57,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The sum of the grades is: 72\n", + "Sorted list of the performance of 3 students: [5, 5, 5]\n", + "The number of occurrences of the score '5' is: 3\n" + ] + } + ], "source": [ - "sutudents_grades = []\n", + "students_grades = []\n", "for i in range(5):\n", - " grades_input = float(input(\"Enter the grade of each student: \"))\n", - " sutudents_grades.append(grades_input)\n", + " grades_input = int(input(\"Enter the grade of each student: \"))\n", + " students_grades.append(grades_input)\n", "\n", - "sum_grades = sum(sutudents_grades)\n", + "sum_grades = sum(students_grades)\n", "students_selection = sutudents_grades[0:5:2]\n", "students_selection.sort()\n", "\n", "print (f\"The sum of the grades is: {sum_grades}\")\n", "print (f\"Sorted list of the performance of {len(students_selection)} students: {students_selection}\")\n", - "print (\"The number of occurrences of the score '5' is:\", sutudents_grades.count(5))" + "print (\"The number of occurrences of the score '5' is:\", students_selection.count(5))" ] }, { @@ -106,20 +116,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('banana', 'grape')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'apple', 'melon')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'banana', 'kiwi', 'pineapple', 'grape', 'apple', 'melon') 11\n" + ] + } + ], "source": [ "fruits = (\"banana\", \"orange\", \"pineapple\", \"watermelon\", \"grape\")\n", - "print(fruits[0:5])\n", + "print(fruits[0:5:4])\n", "fruits = (\"banana\", \"kiwi\", \"pineapple\", \"watermelon\", \"grape\")\n", "print(fruits)\n", - "fruits_1 = (\"apple\",\"melon\")\n", - "new_fruits = fruits + fruits_1\n", + "extra_fruits = (\"apple\",\"melon\")\n", + "new_fruits = fruits + extra_fruits\n", "print(new_fruits)\n", - "fruits_2 = new_fruits[0:3]\n", - "fruits_3 = new_fruits[3:6]\n", - "mega_fruits = fruits + fruits_2 + fruits_3\n", + "frist_fruits = new_fruits[0:3]\n", + "last_fruits = new_fruits[4:7]\n", + "mega_fruits = fruits + frist_fruits + last_fruits\n", "print(mega_fruits, len(mega_fruits))\n" ] }, @@ -162,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -189,16 +210,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "21\n", + "23\n", + "['end', 'enough', 'had', 'i', 'if', 'it', 'ive', 'know', 'of', 'say', 'some', 'that', 'think', 'those', 'to', 'what', 'who', 'with']\n" + ] + } + ], "source": [ - "set_poem = set(poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").replace(\"\\n\",\" \").lower().split(\" \"))\n", - "set_new_poem = set(new_poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"'\",\"\").replace(\"\\n\",\" \").lower().split(\" \")) \n", + "join_poem = ' '.join(poem.split(' ')) # covierto a lista usando espacios y vuelvo a unir con un solo espacio. Elimino espacios simple, dobles...\n", + "join_new_poem = ' '.join(new_poem.split(' '))\n", + "clean_poem = join_poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").lower().split(\" \") # elimino signos de puntiacion y convierto a lista usando como separador los espacios blancos\n", + "clean_new_poem = join_new_poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"'\",\"\").lower().split(\" \") # No convierto aun a set porque me separía por letras y no por palabras al ser aun un string\n", + "set_poem = set(clean_poem) # convierto a ser la lista \n", + "set_new_poem = set(clean_new_poem)\n", "unique_words_poem = set_poem - set_new_poem\n", "unique_words_new_poem = set_new_poem - set_poem\n", - "print(unique_words_poem)\n", - "print(unique_words_new_poem)\n", + "print(len(unique_words_poem))\n", + "print(len(unique_words_new_poem))\n", "unique_words = set_poem & set_new_poem\n", "print(sorted(unique_words))" ] @@ -239,7 +274,7 @@ "metadata": {}, "outputs": [], "source": [ - "grades[\"Bob\"][\"Philosophy\"]=100\n", + "grades[\"Bob\"][\"Philosophy\"] = 100\n", "print(grades)" ] }, @@ -273,25 +308,17 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'Physics': 75, 'Math': 85, 'Chemistry': 60, 'Philosophy': 90}\n" - ] - } - ], + "outputs": [], "source": [ "keys = ['Physics', 'Math', 'Chemistry', 'Philosophy']\n", "values = [75, 85, 60,90]\n", "\n", - "grades = dict(zip(keys,values))\n", + "subject_scores_dict = dict(zip(keys,values))\n", "\n", "\n", - "print (grades)" + "print(subject_scores_dict)" ] }, { @@ -320,22 +347,11 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'Chemistry'" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "min(grades, key=grades.get)" + "min_subject = min(grades, key=grades.get)" ] }, { From a07e64b3b02342e264d982aad2c7a2637eeb7326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Wed, 15 Apr 2026 17:46:09 +0200 Subject: [PATCH 3/5] Update lab-python-data-structures.ipynb update --- lab-python-data-structures.ipynb | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index d9c9987..d43ab16 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -57,16 +57,16 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The sum of the grades is: 72\n", - "Sorted list of the performance of 3 students: [5, 5, 5]\n", - "The number of occurrences of the score '5' is: 3\n" + "The sum of the grades is: 7\n", + "Sorted list of the performance of 3 students: [0, 0, 0]\n", + "The number of occurrences of the score '5' is: 0\n" ] } ], @@ -77,7 +77,7 @@ " students_grades.append(grades_input)\n", "\n", "sum_grades = sum(students_grades)\n", - "students_selection = sutudents_grades[0:5:2]\n", + "students_selection = students_grades[0:5:2]\n", "students_selection.sort()\n", "\n", "print (f\"The sum of the grades is: {sum_grades}\")\n", @@ -116,20 +116,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('banana', 'grape')\n", - "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape')\n", - "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'apple', 'melon')\n", - "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'banana', 'kiwi', 'pineapple', 'grape', 'apple', 'melon') 11\n" - ] - } - ], + "outputs": [], "source": [ "fruits = (\"banana\", \"orange\", \"pineapple\", \"watermelon\", \"grape\")\n", "print(fruits[0:5:4])\n", @@ -183,7 +172,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ From d74c501e72e7a19617e72f72997f3c559fb94636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Wed, 15 Apr 2026 17:55:05 +0200 Subject: [PATCH 4/5] Update lab-python-data-structures.ipynb update --- lab-python-data-structures.ipynb | 50 +++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index d43ab16..634decf 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -116,20 +116,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('banana', 'grape')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'apple', 'melon')\n", + "('banana', 'kiwi', 'pineapple', 'watermelon', 'grape', 'banana', 'kiwi', 'pineapple', 'grape', 'apple', 'melon') 11\n" + ] + } + ], "source": [ "fruits = (\"banana\", \"orange\", \"pineapple\", \"watermelon\", \"grape\")\n", "print(fruits[0:5:4])\n", - "fruits = (\"banana\", \"kiwi\", \"pineapple\", \"watermelon\", \"grape\")\n", + "list_fruits = list(fruits)\n", + "list_fruits[1] = \"kiwi\"\n", + "fruits = tuple(list_fruits)\n", "print(fruits)\n", "extra_fruits = (\"apple\",\"melon\")\n", "new_fruits = fruits + extra_fruits\n", "print(new_fruits)\n", - "frist_fruits = new_fruits[0:3]\n", + "first_fruits = new_fruits[0:3]\n", "last_fruits = new_fruits[4:7]\n", - "mega_fruits = fruits + frist_fruits + last_fruits\n", + "mega_fruits = fruits + first_fruits + last_fruits\n", "print(mega_fruits, len(mega_fruits))\n" ] }, @@ -297,9 +310,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Physics': 75, 'Math': 85, 'Chemistry': 60, 'Philosophy': 90}\n" + ] + } + ], "source": [ "keys = ['Physics', 'Math', 'Chemistry', 'Philosophy']\n", "values = [75, 85, 60,90]\n", @@ -336,11 +357,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Chemistry\n" + ] + } + ], "source": [ - "min_subject = min(grades, key=grades.get)" + "min_subject = min(subject_scores_dict, key=subject_scores_dict.get)\n", + "print(min_subject)" ] }, { From 40d2bc5d47bc8bcfe12a24a7fc25421a0e96b4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Wed, 15 Apr 2026 17:59:42 +0200 Subject: [PATCH 5/5] Update lab-python-data-structures.ipynb update --- lab-python-data-structures.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 634decf..50f677f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -143,7 +143,7 @@ "first_fruits = new_fruits[0:3]\n", "last_fruits = new_fruits[4:7]\n", "mega_fruits = fruits + first_fruits + last_fruits\n", - "print(mega_fruits, len(mega_fruits))\n" + "print(mega_fruits, len(mega_fruits))" ] }, {