From ef10d12d5ae9d6a98a0fb107bad5cc877f0672db Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 20 Sep 2023 10:14:10 +0200 Subject: [PATCH 01/28] added notebook translations.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8a1a923..57e2ac6 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,6 @@ In this repository, you can find all the Notebooks from the book [Learn Python w ## How to download the notebooks Click the green button `< > Code` at the top-right of this page. Then, click on `Download ZIP` + +## Notebooks translations +- Español de México (Mexican Spanish): [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) From f6d3d870d33c73c673b116b1695f640a839061d3 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 20 Sep 2023 10:16:12 +0200 Subject: [PATCH 02/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57e2ac6..2718205 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ In this repository, you can find all the Notebooks from the book [Learn Python w ## How to download the notebooks Click the green button `< > Code` at the top-right of this page. Then, click on `Download ZIP` -## Notebooks translations +## Translations of the notebooks to other languages - Español de México (Mexican Spanish): [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) From 8fef5ec5a9378ff4a7af7290e2e169b2f1b881d5 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 20 Sep 2023 10:26:38 +0200 Subject: [PATCH 03/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2718205..02d51e9 100644 --- a/README.md +++ b/README.md @@ -5,5 +5,5 @@ In this repository, you can find all the Notebooks from the book [Learn Python w ## How to download the notebooks Click the green button `< > Code` at the top-right of this page. Then, click on `Download ZIP` -## Translations of the notebooks to other languages +## Notebooks translated to other languages - Español de México (Mexican Spanish): [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) From a0f2852236e4677a4d32e1e11c594e90946f79db Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 20 Sep 2023 10:28:45 +0200 Subject: [PATCH 04/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02d51e9..67cd290 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ In this repository, you can find all the Notebooks from the book [Learn Python w Click the green button `< > Code` at the top-right of this page. Then, click on `Download ZIP` ## Notebooks translated to other languages -- Español de México (Mexican Spanish): [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) +- Español de México: [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) From a6a8e95a911fdc65a7875aff5cfc1b3f5b4c276b Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Sat, 14 Oct 2023 16:56:10 +0200 Subject: [PATCH 05/28] Adding notebook 22 --- 22_for_recap.ipynb | 283 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 22_for_recap.ipynb diff --git a/22_for_recap.ipynb b/22_for_recap.ipynb new file mode 100644 index 0000000..3a9837d --- /dev/null +++ b/22_for_recap.ipynb @@ -0,0 +1,283 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 22. Recap of the for loop\n", + "\n", + "## Various ways of repeating commands on lists and beyond\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 1. Repeating commands\n", + "\n", + "- Print 3 random numbers between 1 and 10:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import random\n", + "\n", + "for _ in range (3):\n", + " number = random.randint(1,10)\n", + " print (number)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. For loops with lists" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "### 2.1. For loop through *indices*\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Capitalize each string using a for loop through *indices*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "\n", + "for i in range (len(last_names)):\n", + " print (\"The element in position \" + str(i) + \" is: \" + last_names[i])\n", + " last_names[i] = last_names[i].title()\n", + "\n", + "print (last_names)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "### 2.2 For loop through *elements* " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Capitalize each string using a for loop through *elements*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "last_names_upper = [] \n", + " \n", + "for last_name in last_names:\n", + " print (\"The current element is: \" + last_name)\n", + " last_names_upper.append(last_name.title())\n", + "\n", + "print (last_names_upper)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2.3 For loop through *indeces* and *elements* \n", + "\n", + "\n", + "- Capitalize each string using a for loop through and *indeces and elements*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "\n", + "for i,last_name in enumerate (last_names):\n", + " print (\"The element in position \" + str(i) + \" is: \" + last_name)\n", + " last_names[i] = last_name.title()\n", + " \n", + "print (last_names) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2.4 List comprehension \n", + "\n", + "- Capitalize each string using *list comprehension* containing a for loop through *indices*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "last_names = [last_names[i].title() for i in range(len(last_names))] \n", + "print (last_names)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Capitalize each string using *list comprehension* containing a for loop through *elements*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "last_names = [last_name.title() for last_name in last_names]\n", + "print (last_names)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "- Keep and capitalize only the elements shorter than 6 characters:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "last_names = [last_name.title() for last_name in last_names if len(last_name) < 6]\n", + "print (last_names)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Delete elements that are composed of 5 characters:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "last_names = [last_name for last_name in last_names if len(last_name) != 5] \n", + "print (last_names)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Nested for loops \n", + "\n", + "- Given the following list of vowels: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vowels = [\"A\", \"E\", \"I\", \"O\", \"U\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- For each vowel, print all the vowels on the right:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range (len(vowels)): \n", + " print (\"-- \" + vowels[i])\n", + " for j in range(i+1, len(vowels)):\n", + " print (vowels[j])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 7d664c71167ee4865f88cd43a1ec9f4904d1430b Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Sat, 14 Oct 2023 16:58:43 +0200 Subject: [PATCH 06/28] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 67cd290..464cef7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,11 @@ In this repository, you can find all the Notebooks from the book [Learn Python with Jupyter](https://learnpythonwithjupyter.com). ## How to download the notebooks -Click the green button `< > Code` at the top-right of this page. Then, click on `Download ZIP` +Click the green button `< > Code` at the top-right of this page. Then, click `Download ZIP` -## Notebooks translated to other languages +## Download notebooks translated to other languages - Español de México: [here](https://github.com/incognia/Notebooks) by [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) + +## Notebook licenses: +- Code: GNU-GPL v.3 +- Narrative: CC BY-NC-SA From 35970703fcab3517ef2552106abe7282bdcaf67e Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Thu, 19 Oct 2023 09:05:15 +0200 Subject: [PATCH 07/28] changed titles and file names --- 21_list_recap.ipynb => 21_list_overview.ipynb | 4 ++-- 22_for_recap.ipynb => 22_for_overview.ipynb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename 21_list_recap.ipynb => 21_list_overview.ipynb (99%) rename 22_for_recap.ipynb => 22_for_overview.ipynb (99%) diff --git a/21_list_recap.ipynb b/21_list_overview.ipynb similarity index 99% rename from 21_list_recap.ipynb rename to 21_list_overview.ipynb index 2f87991..503b591 100644 --- a/21_list_recap.ipynb +++ b/21_list_overview.ipynb @@ -6,7 +6,7 @@ "tags": [] }, "source": [ - "# 21. Recap of lists \n", + "# 21. Overview of lists \n", "\n", "## Operations, methods, and tricks\n", "\n", @@ -560,7 +560,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.4" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/22_for_recap.ipynb b/22_for_overview.ipynb similarity index 99% rename from 22_for_recap.ipynb rename to 22_for_overview.ipynb index 3a9837d..591ebb0 100644 --- a/22_for_recap.ipynb +++ b/22_for_overview.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 22. Recap of the for loop\n", + "# 22. More about the for loop\n", "\n", "## Various ways of repeating commands on lists and beyond\n", "\n", From d42c8451f7d171f3353cd73bd270ab476136eca2 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Fri, 10 Nov 2023 08:48:09 +0100 Subject: [PATCH 08/28] Delete unwanted comment + typo --- 13_numbers.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/13_numbers.ipynb b/13_numbers.ipynb index cef785c..24e77a6 100644 --- a/13_numbers.ipynb +++ b/13_numbers.ipynb @@ -122,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "7. Modulo `%`: " + "7. Modulo: `%` " ] }, { @@ -353,7 +353,7 @@ "outputs": [], "source": [ "# first input\n", - "first_number = float (input (\"Insert the first number: \")) # change wrt above \n", + "first_number = float (input (\"Insert the first number: \")) \n", "\n", "# operator\n", "operator = input (\"Insert an arithmetic operator: \")\n", @@ -400,7 +400,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.4" }, "widgets": { "application/vnd.jupyter.widget-state+json": { From f4c9e77785a984be693ed027977e9d3d04d669ac Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 11 Dec 2023 15:34:27 +0100 Subject: [PATCH 09/28] Upload notebook 23 --- .gitignore | 2 + 23_list_of_lists.ipynb | 274 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 .gitignore create mode 100644 23_list_of_lists.ipynb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a207f02 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.ipynb_checkpoints/* diff --git a/23_list_of_lists.ipynb b/23_list_of_lists.ipynb new file mode 100644 index 0000000..8df74ca --- /dev/null +++ b/23_list_of_lists.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 23. List of lists\n", + "\n", + "\n", + "## Slicing, nested for loops, and flattening\n", + "\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Slicing" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list of lists: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "animals = [[\"dog\", \"cat\"], [\"cow\", \"sheep\", \"horse\", \"chicken\", \"rabbit\"], [\"panda\", \"elephant\", \"giraffe\", \"penguin\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print the sub-lists containing pets, farm animals, and wild animals: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (animals[0])\n", + "print (animals[1])\n", + "print (animals[2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print the sub-elements \"cat\", \"rabbit\", and from \"panda\" to \"giraffe\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (animals[0][1])\n", + "print (animals[1][-1])\n", + "print (animals[2][:3])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. Nested for loops" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list of lists: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sports = [[\"skiing\", \"skating\", \"curling\"], [\"canoeing\", \"cycling\", \"swimming\", \"surfing\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print the sub-list elements one-by-one using a nested for loops through *indices*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range (len(sports)): \n", + " for j in range (len(sports[i])):\n", + " print (sports[i][j])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print the sub-list elements one-by-one using a nested for loops through *values*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for seasonal_sports in sports:\n", + " for sport in seasonal_sports:\n", + " print (sport)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## Flattening" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list of lists:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "instruments = [[\"contrabass\", \"cello\", \"clarinet\"],[\"gong\", \"guitar\"],[\"tambourine\", \"trumpet\", \"trombone\", \"triangle\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Flatten the list using a nested for loop through *indices*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "flat_instruments = []\n", + "for i in range(len(instruments)):\n", + " for j in range (len(instruments[i])):\n", + " flat_instruments.append(instruments[i][j])\n", + "print (flat_instruments)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Flatten the list using a nested for loop through *elements*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "flat_instruments = []\n", + "for group in instruments:\n", + " for instrument in group:\n", + " flat_instruments.append(instrument)\n", + "print (flat_instruments)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Flatten the list using a for loop and list concatenation:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "flat_instruments = []\n", + "for group in instruments:\n", + " flat_instruments += group\n", + "print (flat_instruments)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Flatten the list using list comprehension:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "instruments = [instrument for group in instruments for instrument in group]\n", + "print (instruments)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From cd453f60a171c4286cbf572f4cddff851bf1ea92 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Fri, 26 Jan 2024 17:21:56 +0100 Subject: [PATCH 10/28] Publish Ch. 24 --- 24_dictionaries.ipynb | 290 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 24_dictionaries.ipynb diff --git a/24_dictionaries.ipynb b/24_dictionaries.ipynb new file mode 100644 index 0000000..5052467 --- /dev/null +++ b/24_dictionaries.ipynb @@ -0,0 +1,290 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 24. Inventory at the English bookstore \n", + "\n", + "\n", + "## Dictionary\n", + "\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You are the owner of an English bookstore, and these are some classics you sell:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "classics = {\"Austen\":\"Pride and Prejudice\", \n", + " \"Shelley\":\"Frankenstein\", \n", + " \"Joyce\":\"Ulyssessss\"}\n", + "print (classics)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You are conducting an inventory, and you need to print authors and titles: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# as dict_items\n", + "print (classics.items())\n", + "# as a list of tuples\n", + "print (list(classics.items()))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Then, you need to print authors and titles separately:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# authors as dict_items\n", + "print (classics.keys())\n", + "# authors as a list \n", + "print (list(classics.keys()))\n", + "\n", + "# titles as dict_values\n", + "print (classics.values())\n", + "# titles as a list\n", + "print (list(classics.values()))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You notice that the title of the last book is wrong, so you correct it:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (\"Wrong title: \" + classics[\"Joyce\"])\n", + "classics[\"Joyce\"] = \"Ulysses\"\n", + "print (\"Corrected title: \" + classics[\"Joyce\"])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Then you add two new books that have just arrived: *Gulliver's travels* by Swift and *Jane Eyre* by Bronte:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# adding the first book (syntax 1)\n", + "classics[\"Swift\"] = \"Gulliver's travels\"\n", + "print (classics)\n", + "\n", + "# adding the second book (syntax 2)\n", + "classics.update({\"Bronte\":\"Jane Eyre\"})\n", + "print (classics)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Finally you remove the books by Austen and Joyce because you have just sold them: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# deleting the first book (syntax 1)\n", + "del classics[\"Austen\"]\n", + "print (classics)\n", + "\n", + "# deleting the second book (syntax 2)\n", + "classics.pop(\"Joyce\")\n", + "print (classics)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## List of dictionaries (*In more depth* section)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list of dictionaries:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "countries = [{\"name\": \"China\", \"capital\": \"Bejing\"},\n", + " {\"name\": \"France\", \"capital\": \"Paris\"},]\n", + "print (countries)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Add a list element:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "countries.append({\"name\": \"Brazil\", \"capital\": \"Brasilia\"})\n", + "print (countries)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Slice the second element:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "print (countries [1])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print list elements using a for loop through elements and a for loop through indices:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# for loop though elements\n", + "print (\"-> for loop though elements\")\n", + "for country in countries:\n", + " print (country)\n", + "\n", + "# for loop though indices\n", + "print (\"-> for loop though indices\")\n", + "for i in range (len(countries)):\n", + " print (countries[i])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print the country names using a for loop through elements and a for loop through indices:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# for loop though elements\n", + "print (\"-> for loop though elements\") \n", + "for country in countries:\n", + " print (country[\"name\"])\n", + " \n", + "# for loop though indices\n", + "print (\"-> for loop though indices\")\n", + "for i in range (len(countries)):\n", + " print (countries[i][\"name\"])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 3396db99a5d2784001927cee6f79ea2933b0f64c Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Fri, 8 Mar 2024 18:14:59 +0100 Subject: [PATCH 11/28] Publish Chapter 25 (+typos in 24) --- 24_dictionaries.ipynb | 4 +- 25_dictionary_list.ipynb | 713 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 715 insertions(+), 2 deletions(-) create mode 100644 25_dictionary_list.ipynb diff --git a/24_dictionaries.ipynb b/24_dictionaries.ipynb index 5052467..e2cce4f 100644 --- a/24_dictionaries.ipynb +++ b/24_dictionaries.ipynb @@ -111,7 +111,7 @@ "outputs": [], "source": [ "# adding the first book (syntax 1)\n", - "classics[\"Swift\"] = \"Gulliver's travels\"\n", + "classics[\"Swift\"] = \"Gulliver's Travels\"\n", "print (classics)\n", "\n", "# adding the second book (syntax 2)\n", @@ -164,7 +164,7 @@ }, "outputs": [], "source": [ - "countries = [{\"name\": \"China\", \"capital\": \"Bejing\"},\n", + "countries = [{\"name\": \"China\", \"capital\": \"Beijing\"},\n", " {\"name\": \"France\", \"capital\": \"Paris\"},]\n", "print (countries)" ] diff --git a/25_dictionary_list.ipynb b/25_dictionary_list.ipynb new file mode 100644 index 0000000..2578e41 --- /dev/null +++ b/25_dictionary_list.ipynb @@ -0,0 +1,713 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 25. Trip to Switzerland\n", + "\n", + "\n", + "## Dictionary with lists as values\n", + "\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Your friend is planning a trip to Switzerland, and he has asked you for some tips. You start with an empty dictionary to fill out:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "tips = {}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- He would like to visit some cities and taste typical food. Therefore, you add some recommendations:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cities': ['Bern', 'Lucern'], 'food': ['chocolate', 'raclette']}\n" + ] + } + ], + "source": [ + "tips[\"cities\"] = [\"Bern\", \"Lucern\"]\n", + "tips[\"food\"] = [\"chocolate\", \"raclette\"]\n", + "print (tips)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Because his stay is four days, you add two more cities and two more dishes:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cities': ['Bern', 'Lucern', 'Lugano'], 'food': ['chocolate', 'raclette']}\n" + ] + } + ], + "source": [ + "tips[\"cities\"].append(\"Lugano\")\n", + "print (tips)\n", + "# using [] and .append() (syntax 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cities': ['Bern', 'Lucern', 'Lugano', 'Geneva'], 'food': ['chocolate', 'raclette']}\n" + ] + } + ], + "source": [ + "tips[\"cities\"] += [\"Geneva\"]\n", + "print (tips)\n", + "# using [] and list concatenation (syntax 2)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cities': ['Bern', 'Lucern', 'Lugano', 'Geneva'], 'food': ['chocolate', 'raclette', 'onion tarte']}\n" + ] + } + ], + "source": [ + "tips.get(\"food\").append(\"onion tarte\")\n", + "print (tips)\n", + "# using get and .append() (syntax 3)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'cities': ['Bern', 'Lucern', 'Lugano', 'Geneva'], 'food': ['chocolate', 'raclette', 'onion tarte', 'fondue']}\n" + ] + } + ], + "source": [ + "tips[\"food\"] = tips.get(\"food\") + [\"fondue\"]\n", + "print (tips)\n", + "# using get and list concatenation (syntax 4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You want to check that the dictionary is correct, so you print all items one by one:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cities ['Bern', 'Lucern', 'Lugano', 'Geneva']\n", + "food ['chocolate', 'raclette', 'onion tarte', 'fondue']\n" + ] + } + ], + "source": [ + "for k,v in tips.items():\n", + " print (k,v)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Finally, you improve the print for improved readability:" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cities: ['Bern', 'Lucern', 'Lugano', 'Geneva']\n", + " food: ['chocolate', 'raclette', 'onion tarte', 'fondue']\n" + ] + } + ], + "source": [ + "for k,v in tips.items():\n", + " print (\"{:>6}: {}\".format(k,v))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "\n", + "## Olympic games" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You are a sports journalist and you have to collect lists of summer and winter sports at the Olympic games. You start with an empty dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "olympic_games = {}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Then you add two summer sports and two winter sports: " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'summer': ['diving', 'swimming'], 'winter': ['alpine skiing', 'figure skeating']}\n" + ] + } + ], + "source": [ + "olympic_games[\"summer\"] = [\"diving\", \"swimming\"]\n", + "olympic_games[\"winter\"] = [\"alpine skiing\", \"figure skeating\"]\n", + "print (olympic_games)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- The lists look a bit short, so you want to add two more summer sports and two more winter sports: " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'summer': ['diving', 'swimming', 'rowing'],\n", + " 'winter': ['alpine skiing', 'figure skeating']}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# using [] and .append() (syntax 1)\n", + "olympic_games[\"summer\"].append(\"rowing\")\n", + "olympic_games" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'summer': ['diving', 'swimming', 'rowing', 'sailing'], 'winter': ['alpine skiing', 'figure skeating']}\n" + ] + } + ], + "source": [ + "# using [] and list concatenation (syntax 2)\n", + "olympic_games[\"summer\"] += [\"sailing\"]\n", + "print (olympic_games)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'summer': ['diving', 'swimming', 'rowing', 'sailing'], 'winter': ['alpine skiing', 'figure skeating', 'snowboad']}\n" + ] + } + ], + "source": [ + "# using get and .append() (syntax 3)\n", + "olympic_games.get(\"winter\").append(\"snowboad\")\n", + "print (olympic_games)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'summer': ['diving', 'swimming', 'rowing', 'sailing'], 'winter': ['alpine skiing', 'figure skeating', 'snowboad', 'bobsleigh']}\n" + ] + } + ], + "source": [ + "# using get and list concatenation (syntax 4)\n", + "olympic_games[\"winter\"] = olympic_games.get(\"winter\") + [\"bobsleigh\"]\n", + "print (olympic_games)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You print out all items one by one in two different ways:" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-> summer ['diving', 'swimming', 'rowing', 'sailing']\n", + "-> winter ['alpine skiing', 'figure skeating', 'snowboad', 'bobsleigh']\n" + ] + } + ], + "source": [ + "for k,v in olympic_games.items():\n", + " print (\"-> \",k,v)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " summer: ['diving', 'swimming', 'rowing', 'sailing']\n", + " winter: ['alpine skiing', 'figure skeating', 'snowboad', 'bobsleigh']\n" + ] + } + ], + "source": [ + "for k,v in olympic_games.items(): \n", + " print (\"{:>20}: {}\".format(k,v))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- And finally you want to print out only the sports lists:" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['diving', 'swimming', 'rowing', 'sailing']\n", + "['alpine skiing', 'figure skeating', 'snowboad', 'bobsleigh']\n" + ] + } + ], + "source": [ + "for v in olympic_games.values():\n", + " print (v)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "\n", + "## Teaching python" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You are teaching python to some students and you want to list their names according to the course they are attending. You start by creating a dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "students = {}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- So far you have two students for the basic course and three students for the advanced course. You add their names to the dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'basic': ['Paul', 'Laura'], 'advanced': ['Mohammed', 'Geetha', 'Maria']}\n" + ] + } + ], + "source": [ + "students[\"basic\"] = [\"Paul\", \"Laura\"]\n", + "students[\"advanced\"] = [\"Mohammed\", \"Geetha\", \"Maria\"]\n", + "print (students)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You have just got four new registrations, three for the basic course, and one for the advanced course. You add the new students' names to the dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'basic': ['Paul', 'Laura', 'Tom'],\n", + " 'advanced': ['Mohammed', 'Geetha', 'Maria']}" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# using [] and .append() (syntax 1)\n", + "students[\"basic\"].append(\"Tom\")\n", + "students" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'basic': ['Paul', 'Laura', 'Tom', 'Juhee'], 'advanced': ['Mohammed', 'Geetha', 'Maria']}\n" + ] + } + ], + "source": [ + "# using [] and list concatenation (syntax 2)\n", + "students[\"basic\"] += [\"Juhee\"]\n", + "print (students)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'basic': ['Paul', 'Laura', 'Tom', 'Juhee'], 'advanced': ['Mohammed', 'Geetha', 'Maria', 'Matt']}\n" + ] + } + ], + "source": [ + "# using get and .append() (syntax 3)\n", + "students.get(\"advanced\").append(\"Matt\")\n", + "print (students)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'basic': ['Paul', 'Laura', 'Tom', 'Juhee', 'Marc'], 'advanced': ['Mohammed', 'Geetha', 'Maria', 'Matt']}\n" + ] + } + ], + "source": [ + "# using get and list concatenation (syntax 4)\n", + "students[\"basic\"] = students.get(\"basic\") + [\"Marc\"]\n", + "print (students)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- After checking the background of one of your basic class students, you realize that she/he does not need the basic course. So you move her/him from the basic to the advanced course:" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'basic': ['Paul', 'Tom', 'Juhee', 'Marc'], 'advanced': ['Mohammed', 'Geetha', 'Maria', 'Matt', 'Laura']}\n" + ] + } + ], + "source": [ + "students[\"basic\"].remove(\"Laura\")\n", + "students[\"advanced\"].append(\"Laura\")\n", + "print (students)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You print out all items one by one in two different ways:" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-> basic ['Paul', 'Tom', 'Juhee', 'Marc']\n", + "-> advanced ['Mohammed', 'Geetha', 'Maria', 'Matt', 'Laura']\n" + ] + } + ], + "source": [ + "for k,v in students.items():\n", + " print (\"->\",k,v)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " basic: ['Paul', 'Tom', 'Juhee', 'Marc']\n", + "advanced: ['Mohammed', 'Geetha', 'Maria', 'Matt', 'Laura']\n" + ] + } + ], + "source": [ + "for k,v in students.items():\n", + " print (\"{:>8}: {}\".format(k,v))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- And finally you print out only the course names: " + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "basic\n", + "advanced\n" + ] + } + ], + "source": [ + "for k in students.keys():\n", + " print (k)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 56ac847a2a01ab36a60051f1a85fed01db9f1f4d Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 24 Apr 2024 10:40:28 +0200 Subject: [PATCH 12/28] Publish Ch. 26 --- 26_dictionary_use.ipynb | 277 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 26_dictionary_use.ipynb diff --git a/26_dictionary_use.ipynb b/26_dictionary_use.ipynb new file mode 100644 index 0000000..50c44e8 --- /dev/null +++ b/26_dictionary_use.ipynb @@ -0,0 +1,277 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 26. Counting, compressing, and sorting\n", + "\n", + "\n", + "## What are dictionaries for?\n", + "\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/) \n", + "Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 1. Counting elements" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following string:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "greetings = \"hello! how are you?\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Create a dictionary where the keys are the letters of the alphabet found in the string, and the corresponding values are the number of times each letter is present. Write the code in two ways: (1) using `if`/`else`, and (2) using `.get()` \n", + "\n", + "1. Using `if`/`else`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "letter_counter = {}\n", + "\n", + "for letter in greetings:\n", + " if letter not in letter_counter.keys():\n", + " letter_counter[letter] = 1\n", + " else:\n", + " letter_counter[letter] += 1 \n", + "\n", + "for k, v in letter_counter.items():\n", + " print (k, v)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "2. Using `.get()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "letter_counter = {}\n", + "\n", + "for letter in greetings:\n", + " letter_counter[letter] = letter_counter.get(letter, 0) + 1\n", + "\n", + "for k, v in letter_counter.items():\n", + " print (k, v) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Compressing information" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sparse_vector = [0,0,0,1,0,7,0,0,4,0,0,0,8,0,0,0,6,0,0,0,0,0,0,0,9,0,0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Convert it into a dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create the dictionary\n", + "sparse_dict = {}\n", + "for i in range(len(sparse_vector)):\n", + " if sparse_vector[i] != 0:\n", + " sparse_dict[i] = sparse_vector[i]\n", + "\n", + "# save the list length \n", + "sparse_dict[\"length\"] = len(sparse_vector) \n", + " \n", + "# print\n", + "for k,v in sparse_dict.items():\n", + " print (k,v) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- How do we get back to the sparse vector? " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create a list of zeros\n", + "sparse_vector_back = [0] * sparse_dict[\"length\"]\n", + "\n", + "# add nonzero values\n", + "for k,v in sparse_dict.items():\n", + " if k != \"length\":\n", + " sparse_vector_back[k] = v \n", + "\n", + "# print\n", + "print (sparse_vector_back)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Sorting dictionary" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following dictionary:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "registry = {\"Shaili\":4, \"Chris\":90, \"Maria\":70}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Sort the dictionary items according to their *keys*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create a new dictionary\n", + "sorted_registry= {}\n", + "\n", + "# sort the keys\n", + "sorted_keys = list(registry.keys())\n", + "sorted_keys.sort()\n", + "\n", + "# fill out the new dictionary\n", + "for k in sorted_keys:\n", + " sorted_registry[k] = registry[k]\n", + " \n", + "print (sorted_registry)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Sort the dictionary items according to their *values*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create a new dictionary\n", + "sorted_registry = {}\n", + "\n", + "# sort keys according to values \n", + "sorted_keys = sorted(registry, key=registry.get) \n", + "\n", + "# fill out the new dictionary\n", + "for k in sorted_keys:\n", + " sorted_registry[k] = registry[k]\n", + " \n", + "print (sorted_registry)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.7" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 964c61dc86c514c7859f7c7ddc436f859007b8da Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 24 Jun 2024 08:44:57 +0200 Subject: [PATCH 13/28] Upload Chapter 27 --- 27_strings_overview.ipynb | 608 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 608 insertions(+) create mode 100644 27_strings_overview.ipynb diff --git a/27_strings_overview.ipynb b/27_strings_overview.ipynb new file mode 100644 index 0000000..acfb018 --- /dev/null +++ b/27_strings_overview.ipynb @@ -0,0 +1,608 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 27. Overview of strings \n", + "\n", + "## Operations, methods, and printing\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 1. String slicing\n", + "\n", + "String slicing is the same as list slicing.\n", + "\n", + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "two_ways = \"rsecwyadrkd\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Extract every second character:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (two_ways[::2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Extract every second character and invert the outcome:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (two_ways[::-2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. \"Arithmetic\" operations among strings\n", + "\n", + "In python, only two \"arithmetic\" operations are possible on strings (same as for lists): \n", + "- Concatenations (`+`)\n", + "- Self-replication (`*`)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Concatenate two strings:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "first = \"sun\"\n", + "second = \"screen\"\n", + "combo = first + second \n", + "print (combo)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Replicate a string 5 times:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "one_smile = \":-)\"\n", + "five_smiles = one_smile * 5\n", + "print (five_smiles)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 3. Replacing or removing parts of strings\n", + "\n", + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favorites = \"I like cooking, my family, and my friends\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Replace** the character at position 0 with `U` using slicing and assignment. What happens?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "favorites[0] = \"U\" " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Redo the same task using slicing and concatenation: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from_position_one = favorites[1:]\n", + "favorites = \"U\" + from_position_one\n", + "print (favorites)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Redo the same task using the string method `.split()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favorites = \"I like cooking, my family, and my friends\"\n", + "\n", + "parts = favorites.split(\"I\")\n", + "print (parts)\n", + "\n", + "favorites = \"U\" + parts[1]\n", + "print (favorites)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Replace** the commas with semicolons using the method `.replace()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favorites = \"I like cooking, my family, and my friends\"\n", + "favorites = favorites.replace(\",\", \";\") #reassingment\n", + "print (favorites)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Remove** the commas:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favorites = \"I like cooking, my family, and my friends\"\n", + "favorites = favorites.replace(\",\", \"\") # two things at once: replace and removing (or using replace to removing)\n", + "print (favorites)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. Searching a substring in a string\n", + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "us = \"we are\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Find the positions of the character `e` using the method `.find()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "positions = us.find(\"e\")\n", + "print (positions)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Find all the positions of the character *e* using an alternative way:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# initializing positions \n", + "positions = []\n", + "\n", + "# find all positions of e\n", + "for i in range(len(us)):\n", + " if us[i] == \"e\":\n", + " positions.append(i)\n", + "print (positions)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Find the position of the character `f` using the method `.find()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "positions = us.find(\"f\")\n", + "print (positions)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 5. Counting the number of substrings in a string" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hobbies = \"I like going to the movies, traveling, and singing\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Count the numbers of substrings `ing` using the method `.count()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "n_substrings = hobbies.count(\"ing\")\n", + "print (n_substrings)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 6. String to list and back \n", + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "string = \"How are you\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Transform the string into a list of strings where each element is a word: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "list_of_strings = string.split() \n", + "print (list_of_strings)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Transform the list of strings back to a string using the method `.join()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "string_from_list = \" \".join(list_of_strings)\n", + "print (string_from_list)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 7. Changing character cases \n", + "- Given the following string: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "greeting = \"Hello! How are you?\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Modify the string to uppercase and lowercase; change to uppercase only the first character of the string and then each word of the string; finally, invert the cases:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# uppercase\n", + "print (greeting.upper())\n", + "# lowercase\n", + "print (greeting.lower())\n", + "# change the first character of the to uppercase\n", + "print (greeting.capitalize())\n", + "# change the first character of each word to uppercase\n", + "print (greeting.title())\n", + "# invert cases\n", + "print (greeting.swapcase())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 8. Printing variables" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following string:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "part_of_day = \"morning\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print `Good morning!` in 4 ways, using (1) string concatenation, (2) comma separation, (3) the method `.format()`, and (4) *f-strings*, and notice the differences:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) string concatenation\n", + "print (\"Good \" + part_of_day + \"!\")\n", + "# (2) variable separation by comma\n", + "print (\"Good\", part_of_day, \"!\")\n", + "# (3) the method .format()\n", + "print (\"Good {}!\".format(part_of_day))\n", + "# (4) f-strings\n", + "print (f\"\"\"Good {part_of_day}!\"\"\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given a string and a numerical variable:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "part_of_day = \"morning\"\n", + "time_of_day = 10" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print \n", + " `Good morning!` \n", + " `It's 10a.m.` \n", + " using the same four ways as above (note that the sentences are on two separate lines):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) string concatenation\n", + "print (\"Good \" + part_of_day + \"!\\nIt's \" + str(time_of_day) + \"a.m.\")\n", + "# (2) variable separation by comma\n", + "print (\"Good\", part_of_day, \"!\\nIt's\", time_of_day, \"a.m\")\n", + "# (3) the method .format()\n", + "print (\"Good {}!\\nIt's {}a.m.\".format(part_of_day, time_of_day))\n", + "# (4) f-strings\n", + "print (f\"\"\"Good {part_of_day}! \n", + "It's {time_of_day}a.m.\"\"\")\n", + "# notes:\n", + "# - apostrophe with single quote requires \\' (see first line It's)\n", + "# - use of \\n\n", + "# - with f-strings one can go to a new line if using triple quotes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the numerical variable:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "number = 1.2345" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print `The number is 1.23` (only the first two decimals) using the methods above and (5) percent formatting:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) string concatenation\n", + "print(\"The number is \" + str(round(number, 2)))\n", + "# (2) variable separation by comma\n", + "print(\"The number is\", round(number, 2))\n", + "# (3) the method .format()\n", + "print(\"The number is {:.2f}\".format(number))\n", + "# (4) f-strings\n", + "print(f\"\"\"The number is {number:.2f}\"\"\")\n", + "# (5) percent formatting\n", + "print(\"The number is %.2f\" % number)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From a2af2ac5174a1e232999e8310ef36d1c060a3426 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 24 Jun 2024 09:10:26 +0200 Subject: [PATCH 14/28] correct --- 27_strings_overview.ipynb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/27_strings_overview.ipynb b/27_strings_overview.ipynb index acfb018..11e750d 100644 --- a/27_strings_overview.ipynb +++ b/27_strings_overview.ipynb @@ -555,7 +555,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Print `The number is 1.23` (only the first two decimals) using the methods above and (5) percent formatting:" + "- Print `The number is 1.23` (only the first two decimals) using the four methods:" ] }, { @@ -571,10 +571,15 @@ "# (3) the method .format()\n", "print(\"The number is {:.2f}\".format(number))\n", "# (4) f-strings\n", - "print(f\"\"\"The number is {number:.2f}\"\"\")\n", - "# (5) percent formatting\n", - "print(\"The number is %.2f\" % number)" + "print(f\"\"\"The number is {number:.2f}\"\"\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From f8355ede7b6b46a699455dfdaedc346c1b58b7db Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 26 Jun 2024 18:17:42 +0200 Subject: [PATCH 15/28] typo --- 27_strings_overview.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/27_strings_overview.ipynb b/27_strings_overview.ipynb index 11e750d..69fb9bb 100644 --- a/27_strings_overview.ipynb +++ b/27_strings_overview.ipynb @@ -419,7 +419,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Modify the string to uppercase and lowercase; change to uppercase only the first character of the string and then each word of the string; finally, invert the cases:" + "- Modify the string to uppercase and lowercase; change to uppercase only the first character of the string, and then each word of the string; finally, invert the cases:" ] }, { From 5e18682855f61d1c50fef42e5b76f76757db6373 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 9 Sep 2024 12:07:54 +0200 Subject: [PATCH 16/28] Publish Ch. 28 --- 01_string_input_print.ipynb | 15 +- 28_function_inputs.ipynb | 285 ++++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 4 deletions(-) create mode 100644 28_function_inputs.ipynb diff --git a/01_string_input_print.ipynb b/01_string_input_print.ipynb index 6dbb279..eeaf183 100644 --- a/01_string_input_print.ipynb +++ b/01_string_input_print.ipynb @@ -19,7 +19,7 @@ "metadata": {}, "source": [ "---\n", - "## Strings" + "## 1. Writing text: Strings" ] }, { @@ -52,7 +52,7 @@ "metadata": {}, "source": [ "---\n", - "## Asking questions: input()" + "## 2. Asking questions: input()" ] }, { @@ -85,7 +85,7 @@ "metadata": {}, "source": [ "---\n", - "## ASCII art: print()" + "## 3. ASCII art: print()" ] }, { @@ -107,6 +107,13 @@ "print (\" / \\ \")\n", "print (\" (___)___\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -125,7 +132,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/28_function_inputs.ipynb b/28_function_inputs.ipynb new file mode 100644 index 0000000..3317975 --- /dev/null +++ b/28_function_inputs.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 28. Printing *Thank you* cards\n", + "\n", + "## Function inputs\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Basic *Thank you* cards\n", + "- You recently hosted a party, and you want to send *Thank you* cards to those who attended. Create\n", + "a function that takes a first name as an argument and prints a *Thank you* message containing an\n", + "attendee’s name (e.g., *Thank you Maria*): " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def print_thank_you(first_name): \n", + " \"\"\"Prints a string containing \"Thank you\" and a first name\n", + " \n", + " Parameters\n", + " ----------\n", + " first_name: string\n", + " First name of a person\n", + " \"\"\"\n", + " \n", + " print (\"Thank you\", first_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print two *Thank you* cards: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Maria\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Xiao\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Formal *Thank you* cards\n", + "- After a second thought, you decide that it is more appropriate to print formal Thank you cards. Mod-\n", + "ify the previous function to take three arguments—prefix, first name, and last name—and to print\n", + "a thank you message containing them (e.g., *Thank you Mrs. Maria Lopez*): " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def print_thank_you(prefix, first_name, last_name): \n", + " \"\"\"Prints a string containing \"Thank you\" and the inputs\n", + " \n", + " Parameters\n", + " ----------\n", + " prefix: string\n", + " Usually Ms, Mrs, Mr\n", + " first_name: string\n", + " First name of a person\n", + " last_name: string\n", + " Last name of a person\n", + " \"\"\"\n", + "\n", + " print (\"Thank you\", prefix, first_name, last_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print two formal *Thank you* cards: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Mrs\", \"Maria\", \"Lopez\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Mr\", \"Xiao\", \"Li\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Last name missing! \n", + "- You are very happy with the *Thank you* cards, but you suddenly realize that some participants did\n", + "not provide their last names! Adapt the function so that the last name has an empty string as a\n", + "default value:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def print_thank_you(prefix, first_name, last_name=\"\"): \n", + " \"\"\"Prints a string containing \"Thank you\" and the inputs\n", + " \n", + " Parameters\n", + " ----------\n", + " prefix: string\n", + " Usually Ms, Mrs, Mr\n", + " first_name: string\n", + " First name of a person\n", + " last_name: string\n", + " Last name of a person. The default is an empty string\n", + " \"\"\"\n", + " \n", + " print (\"Thank you\", prefix, first_name, last_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print two *Thank you* cards, one with a last name and one without a last name:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Mrs\", \"Maria\", \"Lopez\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print_thank_you(\"Mr\", \"Xiao\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. Prefix and/or first name missing! \n", + "- Finally, you realize that prefix and/or first name are also missing for some guests. Modify the function accordingly:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def print_thank_you(prefix=\"\", first_name=\"\", last_name=\"\"): \n", + " \"\"\"Prints each input and a string containing \"Thank you\" and the inputs\n", + " \n", + " Parameters\n", + " ----------\n", + " prefix: string\n", + " Usually Ms, Mrs, Mr. The default is an empty string\n", + " first_name: string\n", + " First name of a person. The default is an empty string\n", + " last_name: string\n", + " Last name of a person. The default is an empty string\n", + " \"\"\"\n", + " \n", + " print (\"Prefix:\", prefix)\n", + " print (\"First name:\", first_name)\n", + " print (\"Last name:\", last_name)\n", + " print (\"Thank you\", prefix, first_name, last_name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print a *Thank you* card where the *first name* is missing:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "print_thank_you(prefix=\"Mrs\", last_name=\"Lopez\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Print a *Thank you* card where the *prefix* is missing:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "print_thank_you(first_name=\"Xiao\", last_name=\"Li\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 997df00edf53a7884452b139c69a09dafdae43a1 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 16 Dec 2024 18:15:41 +0100 Subject: [PATCH 17/28] Chapter 29 --- .gitignore | 1 + 29_function_outputs.ipynb | 299 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 29_function_outputs.ipynb diff --git a/.gitignore b/.gitignore index a207f02..50bf771 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .ipynb_checkpoints/* +.DS_Store diff --git a/29_function_outputs.ipynb b/29_function_outputs.ipynb new file mode 100644 index 0000000..839781d --- /dev/null +++ b/29_function_outputs.ipynb @@ -0,0 +1,299 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 29. Usernames and passwords\n", + "\n", + "## Function outputs and modular design\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You are the owner of an online shop and need to securely store usernames and passwords of your\n", + "customers. Create a database where usernames are composed of the initial of the customer’s first\n", + "name followed by their last name, and passwords consist of a four-digit code" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 1. Creating a username" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Write a function that creates a username composed of the initial of the first name and the last name:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def create_username (first_name, last_name):\n", + " \"\"\"Create a lowercase username made of initial of first name and last name\n", + " \n", + " Parameters\n", + " ----------\n", + " first_name: string \n", + " First name of a person\n", + " last_name: string\n", + " Last name of a person\n", + " \n", + " Returns \n", + " -------\n", + " username: string\n", + " Created username \n", + " \"\"\"\n", + " \n", + " # concatenate initial of first name and last name\n", + " username = first_name[0] + last_name\n", + " # make sure username is lowercase\n", + " username = username.lower()\n", + " \n", + " # return username\n", + " return username" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Test the function for two customers:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "username_1 = create_username (\"Julia\", \"Smith\") \n", + "print (username_1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "username_2 = create_username (\"Mohammed\", \"Seid\")\n", + "print (username_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Creating a password\n", + "- Write a function that creates a password composed of four random integers:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def create_password():\n", + " \"\"\"Create a password composed of four random integers \n", + " \n", + " Returns \n", + " -------\n", + " password: string\n", + " Created password \n", + " \"\"\"\n", + " \n", + " # create a random number with four digits\n", + " password = str(random.randint(1000,9999))\n", + " \n", + " # return password\n", + " return password" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Test the function for two customers:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "password_1 = create_password()\n", + "print (password_1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "password_2 = create_password()\n", + "print (password_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Creating a database\n", + "\n", + "- Write a function that, given a list of lists of customers, creates and returns a database (i.e., a dictionary) of usernames and passwords. The function also returns the number of customers in the\n", + "database:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def create_database (customers): \n", + " \"\"\"Creates a database as a dictionary with usernames as keys and passwords as values \n", + " \n", + " Parameters\n", + " ----------\n", + " customers : list of lists\n", + " Each sublist contains first name and last name of a customer\n", + " \n", + " Returns \n", + " -------\n", + " db : dictionary\n", + " Created database (shorted as db)\n", + " n_customers : int\n", + " Number of customers in the database\n", + " \"\"\"\n", + " \n", + " # initialize dictionary (i.e. database)\n", + " db = {}\n", + " \n", + " # for each customer\n", + " for customer in customers:\n", + "\n", + " # create username\n", + " username = create_username (customer[0], customer[1])\n", + "\n", + " # create password\n", + " password = create_password() \n", + " \n", + " # add username and password to db\n", + " db[username] = password\n", + " \n", + " # compute number of customers \n", + " n_customers = len(db)\n", + "\n", + " # return dictionary and its length\n", + " return db, n_customers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list of customers:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "customers = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Create the database using two different syntaxes:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create the database - separate returns\n", + "database, number_customers = create_database(customers)\n", + "\n", + "# print the outputs\n", + "print (\"Database:\", database)\n", + "print (\"Number of customers:\", number_customers) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create the database - single return\n", + "outputs = create_database(customers)\n", + "print (\"Output tuple:\", outputs)\n", + "\n", + "# get and print the database\n", + "database = outputs[0]\n", + "print(\"Database:\", database)\n", + " \n", + "# get and print the number of customers\n", + "number_customers = outputs[1]\n", + "print (\"Number of customers:\", number_customers) " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From aa0e4ca552da21bd85953cd359088050a3a990b1 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 3 Feb 2025 17:14:57 +0100 Subject: [PATCH 18/28] Publish Ch 30 --- 29_function_outputs.ipynb | 7 +- 30_function_io_extra.ipynb | 228 +++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+), 4 deletions(-) create mode 100644 30_function_io_extra.ipynb diff --git a/29_function_outputs.ipynb b/29_function_outputs.ipynb index 839781d..af20c02 100644 --- a/29_function_outputs.ipynb +++ b/29_function_outputs.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 29. Usernames and passwords\n", + "# 29. Login database for an online store\n", "\n", "## Function outputs and modular design\n", "\n", @@ -19,8 +19,7 @@ "metadata": {}, "source": [ "- You are the owner of an online shop and need to securely store usernames and passwords of your\n", - "customers. Create a database where usernames are composed of the initial of the customer’s first\n", - "name followed by their last name, and passwords consist of a four-digit code" + "customers. Create a database where usernames are composed of the initial of the customer’s first name followed by their last name (e.g., “jsmith”), and passwords consist of a four-digit code" ] }, { @@ -45,7 +44,7 @@ "outputs": [], "source": [ "def create_username (first_name, last_name):\n", - " \"\"\"Create a lowercase username made of initial of first name and last name\n", + " \"\"\"Create a lowercase username made of initial of first name and full last name\n", " \n", " Parameters\n", " ----------\n", diff --git a/30_function_io_extra.ipynb b/30_function_io_extra.ipynb new file mode 100644 index 0000000..51d8162 --- /dev/null +++ b/30_function_io_extra.ipynb @@ -0,0 +1,228 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 30. Free ticket at the museum\n", + "\n", + "## Input validation and outputs variations\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- You work at a museum and have to update the online system to buy tickets. The update is that people who are 65 and older now qualify for a free ticket. Write a function that asks visitors to enter their prefix, last name, and age; checks the *types* and *values* of these inputs; and returns a message telling the visitor if they are eligible for a free ticket." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def free_museum_ticket(prefix, last_name, age): \n", + " \"\"\"Returns a message containing inputs and free ticket eligibility based on age\n", + " E.g. Mrs. Holmes, you are eligible for a free museum ticket because you are 66\n", + " \n", + " Parameters\n", + " ----------\n", + " prefix : string\n", + " Ms, Mrs, Mr\n", + " last_name : string\n", + " Last name of a visitor\n", + " age : integer\n", + " Age of a visitor\n", + " \n", + " Returns\n", + " -------\n", + " string \n", + " Message containing visitor inputs and eligibility\n", + " \"\"\"\n", + " \n", + " # --- checking parameter types ---\n", + " \n", + " # the type of prefix must be string\n", + " if not isinstance (prefix, str): \n", + " raise TypeError (\"prefix must be a string\")\n", + " \n", + " # the type of last_name must be string\n", + " if not isinstance (last_name, str): \n", + " raise TypeError (\"last_name must be a string\")\n", + " \n", + " # the type of age must be integer\n", + " if not isinstance (age, int): \n", + " raise TypeError (\"age must be an integer\") \n", + "\n", + " \n", + " # --- checking parameter values ---\n", + " \n", + " # prefix must be Ms, Mrs, or Mr\n", + " if prefix not in [\"Ms\", \"Mrs\", \"Mr\"]:\n", + " raise ValueError (\"prefix must be Ms, Mrs, or Mr\")\n", + " \n", + " # last_name must contain only characters \n", + " if not last_name.isalpha():\n", + " raise ValueError (\"last_name must contain only letters\")\n", + " \n", + " # age has to be between 0 and 125\n", + " if age < 0 or age > 125:\n", + " raise ValueError (\"age must be between 0 and 125\")\n", + "\n", + " \n", + " # --- returning output ---\n", + "\n", + " if age >= 65:\n", + " return prefix + \". \" + last_name + \", you are eligible for a free museum ticket because you are \" + str(age)\n", + " else:\n", + " return prefix + \". \" + last_name + \", you are not eligible for a free museum ticket because you are \" + str(age) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Call the function checking the parameter *types*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking prefix type\n", + "message = free_museum_ticket(1, \"Holmes\", 66)\n", + "print (message)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking last_name type\n", + "message = free_museum_ticket(\"Mrs\", 1.2, 66)\n", + "print (message)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking age type\n", + "message = free_museum_ticket(\"Mrs\", \"Holmes\", \"Hi\") \n", + "print (message)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Call the function checking parameter *values*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking prefix value\n", + "message = free_museum_ticket(\"Dr\", \"Holmes\", 66)\n", + "print (message)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking last_name value\n", + "message = free_museum_ticket(\"Mrs\", \"82\", 66)\n", + "print (message)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# checking age value\n", + "message = free_museum_ticket(\"Mrs\", \"Holmes\", 130)\n", + "print (message)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Call the function testing the two possible returns:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# person is eligible\n", + "message = free_museum_ticket(\"Mrs\", \"Holmes\", 66)\n", + "print (message)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# person is not eligible\n", + "message = free_museum_ticket(\"Mrs\", \"Choi\", 38)\n", + "print (message)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 3f3912fd269ba51ec7f7fb321dcd8d07ff46303c Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 3 Feb 2025 17:19:04 +0100 Subject: [PATCH 19/28] typo --- 29_function_outputs.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/29_function_outputs.ipynb b/29_function_outputs.ipynb index af20c02..bb261f9 100644 --- a/29_function_outputs.ipynb +++ b/29_function_outputs.ipynb @@ -18,8 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- You are the owner of an online shop and need to securely store usernames and passwords of your\n", - "customers. Create a database where usernames are composed of the initial of the customer’s first name followed by their last name (e.g., “jsmith”), and passwords consist of a four-digit code" + "- You are the owner of an online store and need to securely store usernames and passwords of your customers. Create a database where usernames are composed of the initial of the customer’s first name followed by their last name (e.g., “jsmith”), and passwords consist of a four-digit code" ] }, { From 1a056af4f72abe98a170f51c2063ecb126f4ea0f Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Fri, 14 Feb 2025 14:22:57 +0100 Subject: [PATCH 20/28] typos --- 01_string_input_print.ipynb | 9 +-------- 02_variables.ipynb | 10 +++++++--- 03_list_if_in_else.ipynb | 4 ++-- 04_list_append_remove.ipynb | 10 +++++++--- 13_numbers.ipynb | 6 +++--- 21_list_overview.ipynb | 2 +- 22_for_overview.ipynb | 2 +- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/01_string_input_print.ipynb b/01_string_input_print.ipynb index eeaf183..b18f3f3 100644 --- a/01_string_input_print.ipynb +++ b/01_string_input_print.ipynb @@ -93,7 +93,7 @@ "metadata": {}, "source": [ " \n", - "- Look at the following example and run the cells:" + "- Look at the following example and run the cell:" ] }, { @@ -107,13 +107,6 @@ "print (\" / \\ \")\n", "print (\" (___)___\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/02_variables.ipynb b/02_variables.ipynb index b5b4de8..3375860 100644 --- a/02_variables.ipynb +++ b/02_variables.ipynb @@ -84,7 +84,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "favorite_food = input (\"What is your favorite food?\")" @@ -93,7 +95,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print (\"Hi! My name is \" + name)\n", @@ -118,7 +122,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/03_list_if_in_else.ipynb b/03_list_if_in_else.ipynb index 8a9cf58..9019b4c 100644 --- a/03_list_if_in_else.ipynb +++ b/03_list_if_in_else.ipynb @@ -23,7 +23,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- You are the owner of a bookstore. n the programming shelf there are:" + "- You are the owner of a bookstore. In the programming shelf there are:" ] }, { @@ -89,7 +89,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/04_list_append_remove.ipynb b/04_list_append_remove.ipynb index 683592c..d583213 100644 --- a/04_list_append_remove.ipynb +++ b/04_list_append_remove.ipynb @@ -2,7 +2,9 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "# 4. Grocery shopping\n", "\n", @@ -70,7 +72,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "item_to_remove = input(\"What do I have to remove?\")\n", @@ -100,7 +104,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/13_numbers.ipynb b/13_numbers.ipynb index 24e77a6..917cdae 100644 --- a/13_numbers.ipynb +++ b/13_numbers.ipynb @@ -309,9 +309,9 @@ "elif operator == \"*\":\n", " result = first_number * second_number\n", "elif operator == \"**\":\n", - " result = first_number / second_number\n", - "elif operator == \"/\":\n", " result = first_number ** second_number\n", + "elif operator == \"/\":\n", + " result = first_number / second_number\n", "elif operator == \"//\":\n", " result = first_number // second_number \n", "elif operator == \"%\": \n", @@ -400,7 +400,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/21_list_overview.ipynb b/21_list_overview.ipynb index 503b591..c021014 100644 --- a/21_list_overview.ipynb +++ b/21_list_overview.ipynb @@ -560,7 +560,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/22_for_overview.ipynb b/22_for_overview.ipynb index 591ebb0..f458b38 100644 --- a/22_for_overview.ipynb +++ b/22_for_overview.ipynb @@ -268,7 +268,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.9.6" }, "widgets": { "application/vnd.jupyter.widget-state+json": { From 8eab613dec06e7ddff0e5fa039a9091574e75989 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Mon, 3 Mar 2025 18:55:12 +0100 Subject: [PATCH 21/28] Publish Ch.31 --- 31_recursion.ipynb | 130 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 31_recursion.ipynb diff --git a/31_recursion.ipynb b/31_recursion.ipynb new file mode 100644 index 0000000..b1131e0 --- /dev/null +++ b/31_recursion.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 31. Factorials\n", + "\n", + "## Recursive functions\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Write a function that calculates the factorial of a given integer using a for loop:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def factorial_for (n):\n", + " \"\"\"Calculates the factorial of a given integer using a for loop\n", + "\n", + " Parameters\n", + " ----------\n", + " n : integer\n", + " The input integer \n", + "\n", + " Returns\n", + " -------\n", + " factorial : integer \n", + " The factorial of the input integer\n", + " \"\"\"\n", + "\n", + " # initialize the result to one\n", + " factorial = 1\n", + "\n", + " # for each integer between 2 and the input integer\n", + " for i in range (2, n+1):\n", + " # multiply the current result for the current integer \n", + " factorial *= i\n", + "\n", + " # return the result\n", + " return factorial\n", + "\n", + "# call the function\n", + "fact = factorial_for (4)\n", + "print (fact)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Compare the previous iterative function with the following recursive function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def factorial_rec (n):\n", + " \"\"\"Calculates the factorial of a given integer using recursion\n", + "\n", + " Parameters\n", + " ----------\n", + " n : integer\n", + " The input integer \n", + "\n", + " Returns\n", + " -------\n", + " integer \n", + " The factorial of the input integer\n", + " \"\"\"\n", + " \n", + " # if n is greater than 1\n", + " if n > 1: \n", + " # execute the recursion\n", + " return factorial_rec(n-1) * n\n", + " # otherwise\n", + " else: \n", + " # return 1\n", + " return 1 \n", + "\n", + "# call the function\n", + "fact = factorial_rec (4)\n", + "print (fact)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 337d77c014e93b785d2e897a9f43ea837ef3e64a Mon Sep 17 00:00:00 2001 From: Nick Chomey Date: Tue, 11 Mar 2025 09:51:06 -0600 Subject: [PATCH 22/28] uv init --- .python-version | 1 + main.py | 6 + pyproject.toml | 9 + uv.lock | 441 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 457 insertions(+) create mode 100644 .python-version create mode 100644 main.py create mode 100644 pyproject.toml create mode 100644 uv.lock diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/main.py b/main.py new file mode 100644 index 0000000..4b53ea4 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from jupyternotebooksspanish!") + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c7c4005 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "jupyternotebooksspanish" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "ipykernel>=6.29.5", +] diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..a251a47 --- /dev/null +++ b/uv.lock @@ -0,0 +1,441 @@ +version = 1 +revision = 1 +requires-python = ">=3.13" + +[[package]] +name = "appnope" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321 }, +] + +[[package]] +name = "asttokens" +version = "3.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4a/e7/82da0a03e7ba5141f05cce0d302e6eed121ae055e0456ca228bf693984bc/asttokens-3.0.0.tar.gz", hash = "sha256:0dcd8baa8d62b0c1d118b399b2ddba3c4aff271d0d7a9e0d4c1681c79035bbc7", size = 61978 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/25/8a/c46dcc25341b5bce5472c718902eb3d38600a903b14fa6aeecef3f21a46f/asttokens-3.0.0-py3-none-any.whl", hash = "sha256:e3078351a059199dd5138cb1c706e6430c05eff2ff136af5eb4790f9d28932e2", size = 26918 }, +] + +[[package]] +name = "cffi" +version = "1.17.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pycparser" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824", size = 516621 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/f8/dd6c246b148639254dad4d6803eb6a54e8c85c6e11ec9df2cffa87571dbe/cffi-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f3a2b4222ce6b60e2e8b337bb9596923045681d71e5a082783484d845390938e", size = 182989 }, + { url = "https://files.pythonhosted.org/packages/8b/f1/672d303ddf17c24fc83afd712316fda78dc6fce1cd53011b839483e1ecc8/cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0984a4925a435b1da406122d4d7968dd861c1385afe3b45ba82b750f229811e2", size = 178802 }, + { url = "https://files.pythonhosted.org/packages/0e/2d/eab2e858a91fdff70533cab61dcff4a1f55ec60425832ddfdc9cd36bc8af/cffi-1.17.1-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d01b12eeeb4427d3110de311e1774046ad344f5b1a7403101878976ecd7a10f3", size = 454792 }, + { url = "https://files.pythonhosted.org/packages/75/b2/fbaec7c4455c604e29388d55599b99ebcc250a60050610fadde58932b7ee/cffi-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:706510fe141c86a69c8ddc029c7910003a17353970cff3b904ff0686a5927683", size = 478893 }, + { url = "https://files.pythonhosted.org/packages/4f/b7/6e4a2162178bf1935c336d4da8a9352cccab4d3a5d7914065490f08c0690/cffi-1.17.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de55b766c7aa2e2a3092c51e0483d700341182f08e67c63630d5b6f200bb28e5", size = 485810 }, + { url = "https://files.pythonhosted.org/packages/c7/8a/1d0e4a9c26e54746dc08c2c6c037889124d4f59dffd853a659fa545f1b40/cffi-1.17.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c59d6e989d07460165cc5ad3c61f9fd8f1b4796eacbd81cee78957842b834af4", size = 471200 }, + { url = "https://files.pythonhosted.org/packages/26/9f/1aab65a6c0db35f43c4d1b4f580e8df53914310afc10ae0397d29d697af4/cffi-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd398dbc6773384a17fe0d3e7eeb8d1a21c2200473ee6806bb5e6a8e62bb73dd", size = 479447 }, + { url = "https://files.pythonhosted.org/packages/5f/e4/fb8b3dd8dc0e98edf1135ff067ae070bb32ef9d509d6cb0f538cd6f7483f/cffi-1.17.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3edc8d958eb099c634dace3c7e16560ae474aa3803a5df240542b305d14e14ed", size = 484358 }, + { url = "https://files.pythonhosted.org/packages/f1/47/d7145bf2dc04684935d57d67dff9d6d795b2ba2796806bb109864be3a151/cffi-1.17.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:72e72408cad3d5419375fc87d289076ee319835bdfa2caad331e377589aebba9", size = 488469 }, + { url = "https://files.pythonhosted.org/packages/bf/ee/f94057fa6426481d663b88637a9a10e859e492c73d0384514a17d78ee205/cffi-1.17.1-cp313-cp313-win32.whl", hash = "sha256:e03eab0a8677fa80d646b5ddece1cbeaf556c313dcfac435ba11f107ba117b5d", size = 172475 }, + { url = "https://files.pythonhosted.org/packages/7c/fc/6a8cb64e5f0324877d503c854da15d76c1e50eb722e320b15345c4d0c6de/cffi-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a", size = 182009 }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 }, +] + +[[package]] +name = "comm" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e9/a8/fb783cb0abe2b5fded9f55e5703015cdf1c9c85b3669087c538dd15a6a86/comm-0.2.2.tar.gz", hash = "sha256:3fd7a84065306e07bea1773df6eb8282de51ba82f77c72f9c85716ab11fe980e", size = 6210 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/75/49e5bfe642f71f272236b5b2d2691cf915a7283cc0ceda56357b61daa538/comm-0.2.2-py3-none-any.whl", hash = "sha256:e6fb86cb70ff661ee8c9c14e7d36d6de3b4066f1441be4063df9c5009f0a64d3", size = 7180 }, +] + +[[package]] +name = "debugpy" +version = "1.8.13" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/51/d4/f35f539e11c9344652f362c22413ec5078f677ac71229dc9b4f6f85ccaa3/debugpy-1.8.13.tar.gz", hash = "sha256:837e7bef95bdefba426ae38b9a94821ebdc5bea55627879cd48165c90b9e50ce", size = 1641193 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b1/db/ae7cd645c1826aae557cebccbc448f0cc9a818d364efb88f8d80e7a03f41/debugpy-1.8.13-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:31abc9618be4edad0b3e3a85277bc9ab51a2d9f708ead0d99ffb5bb750e18503", size = 2485416 }, + { url = "https://files.pythonhosted.org/packages/ec/ed/db4b10ff3b5bb30fe41d9e86444a08bb6448e4d8265e7768450b8408dd36/debugpy-1.8.13-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0bd87557f97bced5513a74088af0b84982b6ccb2e254b9312e29e8a5c4270eb", size = 4218784 }, + { url = "https://files.pythonhosted.org/packages/82/82/ed81852a8d94086f51664d032d83c7f87cd2b087c6ea70dabec7c1ba813d/debugpy-1.8.13-cp313-cp313-win32.whl", hash = "sha256:5268ae7fdca75f526d04465931cb0bd24577477ff50e8bb03dab90983f4ebd02", size = 5226270 }, + { url = "https://files.pythonhosted.org/packages/15/63/aa92fb341a78ec40f1c414ec7a7885c2ee17032eee00d12cee0cdc502af4/debugpy-1.8.13-cp313-cp313-win_amd64.whl", hash = "sha256:79ce4ed40966c4c1631d0131606b055a5a2f8e430e3f7bf8fd3744b09943e8e8", size = 5268621 }, + { url = "https://files.pythonhosted.org/packages/37/4f/0b65410a08b6452bfd3f7ed6f3610f1a31fb127f46836e82d31797065dcb/debugpy-1.8.13-py2.py3-none-any.whl", hash = "sha256:d4ba115cdd0e3a70942bd562adba9ec8c651fe69ddde2298a1be296fc331906f", size = 5229306 }, +] + +[[package]] +name = "decorator" +version = "5.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/fa/6d96a0978d19e17b68d634497769987b16c8f4cd0a7a05048bec693caa6b/decorator-5.2.1.tar.gz", hash = "sha256:65f266143752f734b0a7cc83c46f4618af75b8c5911b00ccb61d0ac9b6da0360", size = 56711 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 }, +] + +[[package]] +name = "executing" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/91/50/a9d80c47ff289c611ff12e63f7c5d13942c65d68125160cefd768c73e6e4/executing-2.2.0.tar.gz", hash = "sha256:5d108c028108fe2551d1a7b2e8b713341e2cb4fc0aa7dcf966fa4327a5226755", size = 978693 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/8f/c4d9bafc34ad7ad5d8dc16dd1347ee0e507a52c3adb6bfa8887e1c6a26ba/executing-2.2.0-py2.py3-none-any.whl", hash = "sha256:11387150cad388d62750327a53d3339fad4888b39a6fe233c3afbb54ecffd3aa", size = 26702 }, +] + +[[package]] +name = "ipykernel" +version = "6.29.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "comm" }, + { name = "debugpy" }, + { name = "ipython" }, + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "matplotlib-inline" }, + { name = "nest-asyncio" }, + { name = "packaging" }, + { name = "psutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e9/5c/67594cb0c7055dc50814b21731c22a601101ea3b1b50a9a1b090e11f5d0f/ipykernel-6.29.5.tar.gz", hash = "sha256:f093a22c4a40f8828f8e330a9c297cb93dcab13bd9678ded6de8e5cf81c56215", size = 163367 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/5c/368ae6c01c7628438358e6d337c19b05425727fbb221d2a3c4303c372f42/ipykernel-6.29.5-py3-none-any.whl", hash = "sha256:afdb66ba5aa354b09b91379bac28ae4afebbb30e8b39510c9690afb7a10421b5", size = 117173 }, +] + +[[package]] +name = "ipython" +version = "9.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "decorator" }, + { name = "ipython-pygments-lexers" }, + { name = "jedi" }, + { name = "matplotlib-inline" }, + { name = "pexpect", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" }, + { name = "prompt-toolkit" }, + { name = "pygments" }, + { name = "stack-data" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7d/ce/012a0f40ca58a966f87a6e894d6828e2817657cbdf522b02a5d3a87d92ce/ipython-9.0.2.tar.gz", hash = "sha256:ec7b479e3e5656bf4f58c652c120494df1820f4f28f522fb7ca09e213c2aab52", size = 4366102 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/3a/917cb9e72f4e1a4ea13c862533205ae1319bd664119189ee5cc9e4e95ebf/ipython-9.0.2-py3-none-any.whl", hash = "sha256:143ef3ea6fb1e1bffb4c74b114051de653ffb7737a3f7ab1670e657ca6ae8c44", size = 600524 }, +] + +[[package]] +name = "ipython-pygments-lexers" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/33/1f075bf72b0b747cb3288d011319aaf64083cf2efef8354174e3ed4540e2/ipython_pygments_lexers-1.1.1-py3-none-any.whl", hash = "sha256:a9462224a505ade19a605f71f8fa63c2048833ce50abc86768a0d81d876dc81c", size = 8074 }, +] + +[[package]] +name = "jedi" +version = "0.19.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "parso" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/72/3a/79a912fbd4d8dd6fbb02bf69afd3bb72cf0c729bb3063c6f4498603db17a/jedi-0.19.2.tar.gz", hash = "sha256:4770dc3de41bde3966b02eb84fbcf557fb33cce26ad23da12c742fb50ecb11f0", size = 1231287 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl", hash = "sha256:a8ef22bde8490f57fe5c7681a3c83cb58874daf72b4784de3cce5b6ef6edb5b9", size = 1572278 }, +] + +[[package]] +name = "jupyter-client" +version = "8.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jupyter-core" }, + { name = "python-dateutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/71/22/bf9f12fdaeae18019a468b68952a60fe6dbab5d67cd2a103cac7659b41ca/jupyter_client-8.6.3.tar.gz", hash = "sha256:35b3a0947c4a6e9d589eb97d7d4cd5e90f910ee73101611f01283732bd6d9419", size = 342019 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/11/85/b0394e0b6fcccd2c1eeefc230978a6f8cb0c5df1e4cd3e7625735a0d7d1e/jupyter_client-8.6.3-py3-none-any.whl", hash = "sha256:e8a19cc986cc45905ac3362915f410f3af85424b4c0905e94fa5f2cb08e8f23f", size = 106105 }, +] + +[[package]] +name = "jupyter-core" +version = "5.7.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "platformdirs" }, + { name = "pywin32", marker = "platform_python_implementation != 'PyPy' and sys_platform == 'win32'" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/00/11/b56381fa6c3f4cc5d2cf54a7dbf98ad9aa0b339ef7a601d6053538b079a7/jupyter_core-5.7.2.tar.gz", hash = "sha256:aa5f8d32bbf6b431ac830496da7392035d6f61b4f54872f15c4bd2a9c3f536d9", size = 87629 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/fb/108ecd1fe961941959ad0ee4e12ee7b8b1477247f30b1fdfd83ceaf017f0/jupyter_core-5.7.2-py3-none-any.whl", hash = "sha256:4f7315d2f6b4bcf2e3e7cb6e46772eba760ae459cd1f59d29eb57b0a01bd7409", size = 28965 }, +] + +[[package]] +name = "jupyternotebooksspanish" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "ipykernel" }, +] + +[package.metadata] +requires-dist = [{ name = "ipykernel", specifier = ">=6.29.5" }] + +[[package]] +name = "matplotlib-inline" +version = "0.1.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/99/5b/a36a337438a14116b16480db471ad061c36c3694df7c2084a0da7ba538b7/matplotlib_inline-0.1.7.tar.gz", hash = "sha256:8423b23ec666be3d16e16b60bdd8ac4e86e840ebd1dd11a30b9f117f2fa0ab90", size = 8159 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8f/8e/9ad090d3553c280a8060fbf6e24dc1c0c29704ee7d1c372f0c174aa59285/matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca", size = 9899 }, +] + +[[package]] +name = "nest-asyncio" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/83/f8/51569ac65d696c8ecbee95938f89d4abf00f47d58d48f6fbabfe8f0baefe/nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe", size = 7418 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/c4/c2971a3ba4c6103a3d10c4b0f24f461ddc027f0f09763220cf35ca1401b3/nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c", size = 5195 }, +] + +[[package]] +name = "packaging" +version = "24.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451 }, +] + +[[package]] +name = "parso" +version = "0.8.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/66/94/68e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d/parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d", size = 400609 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c6/ac/dac4a63f978e4dcb3c6d3a78c4d8e0192a113d288502a1216950c41b1027/parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18", size = 103650 }, +] + +[[package]] +name = "pexpect" +version = "4.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ptyprocess" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772 }, +] + +[[package]] +name = "platformdirs" +version = "4.3.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/13/fc/128cc9cb8f03208bdbf93d3aa862e16d376844a14f9a0ce5cf4507372de4/platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907", size = 21302 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3c/a6/bc1012356d8ece4d66dd75c4b9fc6c1f6650ddd5991e421177d9f8f671be/platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb", size = 18439 }, +] + +[[package]] +name = "prompt-toolkit" +version = "3.0.50" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "wcwidth" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/e1/bd15cb8ffdcfeeb2bdc215de3c3cffca11408d829e4b8416dcfe71ba8854/prompt_toolkit-3.0.50.tar.gz", hash = "sha256:544748f3860a2623ca5cd6d2795e7a14f3d0e1c3c9728359013f79877fc89bab", size = 429087 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e4/ea/d836f008d33151c7a1f62caf3d8dd782e4d15f6a43897f64480c2b8de2ad/prompt_toolkit-3.0.50-py3-none-any.whl", hash = "sha256:9b6427eb19e479d98acff65196a307c555eb567989e6d88ebbb1b509d9779198", size = 387816 }, +] + +[[package]] +name = "psutil" +version = "7.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2a/80/336820c1ad9286a4ded7e845b2eccfcb27851ab8ac6abece774a6ff4d3de/psutil-7.0.0.tar.gz", hash = "sha256:7be9c3eba38beccb6495ea33afd982a44074b78f28c434a1f51cc07fd315c456", size = 497003 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ed/e6/2d26234410f8b8abdbf891c9da62bee396583f713fb9f3325a4760875d22/psutil-7.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25", size = 238051 }, + { url = "https://files.pythonhosted.org/packages/04/8b/30f930733afe425e3cbfc0e1468a30a18942350c1a8816acfade80c005c4/psutil-7.0.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:39db632f6bb862eeccf56660871433e111b6ea58f2caea825571951d4b6aa3da", size = 239535 }, + { url = "https://files.pythonhosted.org/packages/2a/ed/d362e84620dd22876b55389248e522338ed1bf134a5edd3b8231d7207f6d/psutil-7.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fcee592b4c6f146991ca55919ea3d1f8926497a713ed7faaf8225e174581e91", size = 275004 }, + { url = "https://files.pythonhosted.org/packages/bf/b9/b0eb3f3cbcb734d930fdf839431606844a825b23eaf9a6ab371edac8162c/psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b1388a4f6875d7e2aff5c4ca1cc16c545ed41dd8bb596cefea80111db353a34", size = 277986 }, + { url = "https://files.pythonhosted.org/packages/eb/a2/709e0fe2f093556c17fbafda93ac032257242cabcc7ff3369e2cb76a97aa/psutil-7.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5f098451abc2828f7dc6b58d44b532b22f2088f4999a937557b603ce72b1993", size = 279544 }, + { url = "https://files.pythonhosted.org/packages/50/e6/eecf58810b9d12e6427369784efe814a1eec0f492084ce8eb8f4d89d6d61/psutil-7.0.0-cp37-abi3-win32.whl", hash = "sha256:ba3fcef7523064a6c9da440fc4d6bd07da93ac726b5733c29027d7dc95b39d99", size = 241053 }, + { url = "https://files.pythonhosted.org/packages/50/1b/6921afe68c74868b4c9fa424dad3be35b095e16687989ebbb50ce4fceb7c/psutil-7.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:4cf3d4eb1aa9b348dec30105c55cd9b7d4629285735a102beb4441e38db90553", size = 244885 }, +] + +[[package]] +name = "ptyprocess" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993 }, +] + +[[package]] +name = "pure-eval" +version = "0.2.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cd/05/0a34433a064256a578f1783a10da6df098ceaa4a57bbeaa96a6c0352786b/pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42", size = 19752 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8e/37/efad0257dc6e593a18957422533ff0f87ede7c9c6ea010a2177d738fb82f/pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0", size = 11842 }, +] + +[[package]] +name = "pycparser" +version = "2.22" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1d/b2/31537cf4b1ca988837256c910a668b553fceb8f069bedc4b1c826024b52c/pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6", size = 172736 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/13/a3/a812df4e2dd5696d1f351d58b8fe16a405b234ad2886a0dab9183fb78109/pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc", size = 117552 }, +] + +[[package]] +name = "pygments" +version = "2.19.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 }, +] + +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 }, +] + +[[package]] +name = "pywin32" +version = "309" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/c3/51aca6887cc5e410aa4cdc55662cf8438212440c67335c3f141b02eb8d52/pywin32-309-cp313-cp313-win32.whl", hash = "sha256:008bffd4afd6de8ca46c6486085414cc898263a21a63c7f860d54c9d02b45c8d", size = 8789700 }, + { url = "https://files.pythonhosted.org/packages/dd/66/330f265140fa814b4ed1bf16aea701f9d005f8f4ab57a54feb17f53afe7e/pywin32-309-cp313-cp313-win_amd64.whl", hash = "sha256:bd0724f58492db4cbfbeb1fcd606495205aa119370c0ddc4f70e5771a3ab768d", size = 9496714 }, + { url = "https://files.pythonhosted.org/packages/2c/84/9a51e6949a03f25cd329ece54dbf0846d57fadd2e79046c3b8d140aaa132/pywin32-309-cp313-cp313-win_arm64.whl", hash = "sha256:8fd9669cfd41863b688a1bc9b1d4d2d76fd4ba2128be50a70b0ea66b8d37953b", size = 8453052 }, +] + +[[package]] +name = "pyzmq" +version = "26.2.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "implementation_name == 'pypy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5a/e3/8d0382cb59feb111c252b54e8728257416a38ffcb2243c4e4775a3c990fe/pyzmq-26.2.1.tar.gz", hash = "sha256:17d72a74e5e9ff3829deb72897a175333d3ef5b5413948cae3cf7ebf0b02ecca", size = 278433 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/2e/fa7a91ce349975971d6aa925b4c7e1a05abaae99b97ade5ace758160c43d/pyzmq-26.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:099b56ef464bc355b14381f13355542e452619abb4c1e57a534b15a106bf8e23", size = 942331 }, + { url = "https://files.pythonhosted.org/packages/64/2b/1f10b34b6dc7ff4b40f668ea25ba9b8093ce61d874c784b90229b367707b/pyzmq-26.2.1-cp313-cp313-macosx_10_15_universal2.whl", hash = "sha256:651726f37fcbce9f8dd2a6dab0f024807929780621890a4dc0c75432636871be", size = 1345831 }, + { url = "https://files.pythonhosted.org/packages/4c/8d/34884cbd4a8ec050841b5fb58d37af136766a9f95b0b2634c2971deb09da/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57dd4d91b38fa4348e237a9388b4423b24ce9c1695bbd4ba5a3eada491e09399", size = 670773 }, + { url = "https://files.pythonhosted.org/packages/0f/f4/d4becfcf9e416ad2564f18a6653f7c6aa917da08df5c3760edb0baa1c863/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d51a7bfe01a48e1064131f3416a5439872c533d756396be2b39e3977b41430f9", size = 908836 }, + { url = "https://files.pythonhosted.org/packages/07/fa/ab105f1b86b85cb2e821239f1d0900fccd66192a91d97ee04661b5436b4d/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7154d228502e18f30f150b7ce94f0789d6b689f75261b623f0fdc1eec642aab", size = 865369 }, + { url = "https://files.pythonhosted.org/packages/c9/48/15d5f415504572dd4b92b52db5de7a5befc76bb75340ba9f36f71306a66d/pyzmq-26.2.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:f1f31661a80cc46aba381bed475a9135b213ba23ca7ff6797251af31510920ce", size = 865676 }, + { url = "https://files.pythonhosted.org/packages/7e/35/2d91bcc7ccbb56043dd4d2c1763f24a8de5f05e06a134f767a7fb38e149c/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:290c96f479504439b6129a94cefd67a174b68ace8a8e3f551b2239a64cfa131a", size = 1201457 }, + { url = "https://files.pythonhosted.org/packages/6d/bb/aa7c5119307a5762b8dca6c9db73e3ab4bccf32b15d7c4f376271ff72b2b/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_i686.whl", hash = "sha256:f2c307fbe86e18ab3c885b7e01de942145f539165c3360e2af0f094dd440acd9", size = 1513035 }, + { url = "https://files.pythonhosted.org/packages/4f/4c/527e6650c2fccec7750b783301329c8a8716d59423818afb67282304ce5a/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b314268e716487bfb86fcd6f84ebbe3e5bec5fac75fdf42bc7d90fdb33f618ad", size = 1411881 }, + { url = "https://files.pythonhosted.org/packages/89/9f/e4412ea1b3e220acc21777a5edba8885856403d29c6999aaf00a9459eb03/pyzmq-26.2.1-cp313-cp313-win32.whl", hash = "sha256:edb550616f567cd5603b53bb52a5f842c0171b78852e6fc7e392b02c2a1504bb", size = 581354 }, + { url = "https://files.pythonhosted.org/packages/55/cd/f89dd3e9fc2da0d1619a82c4afb600c86b52bc72d7584953d460bc8d5027/pyzmq-26.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:100a826a029c8ef3d77a1d4c97cbd6e867057b5806a7276f2bac1179f893d3bf", size = 643560 }, + { url = "https://files.pythonhosted.org/packages/a7/99/5de4f8912860013f1116f818a0047659bc20d71d1bc1d48f874bdc2d7b9c/pyzmq-26.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:6991ee6c43e0480deb1b45d0c7c2bac124a6540cba7db4c36345e8e092da47ce", size = 558037 }, + { url = "https://files.pythonhosted.org/packages/06/0b/63b6d7a2f07a77dbc9768c6302ae2d7518bed0c6cee515669ca0d8ec743e/pyzmq-26.2.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:25e720dba5b3a3bb2ad0ad5d33440babd1b03438a7a5220511d0c8fa677e102e", size = 938580 }, + { url = "https://files.pythonhosted.org/packages/85/38/e5e2c3ffa23ea5f95f1c904014385a55902a11a67cd43c10edf61a653467/pyzmq-26.2.1-cp313-cp313t-macosx_10_15_universal2.whl", hash = "sha256:9ec6abfb701437142ce9544bd6a236addaf803a32628d2260eb3dbd9a60e2891", size = 1339670 }, + { url = "https://files.pythonhosted.org/packages/d2/87/da5519ed7f8b31e4beee8f57311ec02926822fe23a95120877354cd80144/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e1eb9d2bfdf5b4e21165b553a81b2c3bd5be06eeddcc4e08e9692156d21f1f6", size = 660983 }, + { url = "https://files.pythonhosted.org/packages/f6/e8/1ca6a2d59562e04d326a026c9e3f791a6f1a276ebde29da478843a566fdb/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:90dc731d8e3e91bcd456aa7407d2eba7ac6f7860e89f3766baabb521f2c1de4a", size = 896509 }, + { url = "https://files.pythonhosted.org/packages/5c/e5/0b4688f7c74bea7e4f1e920da973fcd7d20175f4f1181cb9b692429c6bb9/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b6a93d684278ad865fc0b9e89fe33f6ea72d36da0e842143891278ff7fd89c3", size = 853196 }, + { url = "https://files.pythonhosted.org/packages/8f/35/c17241da01195001828319e98517683dad0ac4df6fcba68763d61b630390/pyzmq-26.2.1-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:c1bb37849e2294d519117dd99b613c5177934e5c04a5bb05dd573fa42026567e", size = 855133 }, + { url = "https://files.pythonhosted.org/packages/d2/14/268ee49bbecc3f72e225addeac7f0e2bd5808747b78c7bf7f87ed9f9d5a8/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:632a09c6d8af17b678d84df442e9c3ad8e4949c109e48a72f805b22506c4afa7", size = 1191612 }, + { url = "https://files.pythonhosted.org/packages/5e/02/6394498620b1b4349b95c534f3ebc3aef95f39afbdced5ed7ee315c49c14/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_i686.whl", hash = "sha256:fc409c18884eaf9ddde516d53af4f2db64a8bc7d81b1a0c274b8aa4e929958e8", size = 1500824 }, + { url = "https://files.pythonhosted.org/packages/17/fc/b79f0b72891cbb9917698add0fede71dfb64e83fa3481a02ed0e78c34be7/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:17f88622b848805d3f6427ce1ad5a2aa3cf61f12a97e684dab2979802024d460", size = 1399943 }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050 }, +] + +[[package]] +name = "stack-data" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "asttokens" }, + { name = "executing" }, + { name = "pure-eval" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521 }, +] + +[[package]] +name = "tornado" +version = "6.4.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/59/45/a0daf161f7d6f36c3ea5fc0c2de619746cc3dd4c76402e9db545bd920f63/tornado-6.4.2.tar.gz", hash = "sha256:92bad5b4746e9879fd7bf1eb21dce4e3fc5128d71601f80005afa39237ad620b", size = 501135 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/26/7e/71f604d8cea1b58f82ba3590290b66da1e72d840aeb37e0d5f7291bd30db/tornado-6.4.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e828cce1123e9e44ae2a50a9de3055497ab1d0aeb440c5ac23064d9e44880da1", size = 436299 }, + { url = "https://files.pythonhosted.org/packages/96/44/87543a3b99016d0bf54fdaab30d24bf0af2e848f1d13d34a3a5380aabe16/tornado-6.4.2-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:072ce12ada169c5b00b7d92a99ba089447ccc993ea2143c9ede887e0937aa803", size = 434253 }, + { url = "https://files.pythonhosted.org/packages/cb/fb/fdf679b4ce51bcb7210801ef4f11fdac96e9885daa402861751353beea6e/tornado-6.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a017d239bd1bb0919f72af256a970624241f070496635784d9bf0db640d3fec", size = 437602 }, + { url = "https://files.pythonhosted.org/packages/4f/3b/e31aeffffc22b475a64dbeb273026a21b5b566f74dee48742817626c47dc/tornado-6.4.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c36e62ce8f63409301537222faffcef7dfc5284f27eec227389f2ad11b09d946", size = 436972 }, + { url = "https://files.pythonhosted.org/packages/22/55/b78a464de78051a30599ceb6983b01d8f732e6f69bf37b4ed07f642ac0fc/tornado-6.4.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bca9eb02196e789c9cb5c3c7c0f04fb447dc2adffd95265b2c7223a8a615ccbf", size = 437173 }, + { url = "https://files.pythonhosted.org/packages/79/5e/be4fb0d1684eb822c9a62fb18a3e44a06188f78aa466b2ad991d2ee31104/tornado-6.4.2-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:304463bd0772442ff4d0f5149c6f1c2135a1fae045adf070821c6cdc76980634", size = 437892 }, + { url = "https://files.pythonhosted.org/packages/f5/33/4f91fdd94ea36e1d796147003b490fe60a0215ac5737b6f9c65e160d4fe0/tornado-6.4.2-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:c82c46813ba483a385ab2a99caeaedf92585a1f90defb5693351fa7e4ea0bf73", size = 437334 }, + { url = "https://files.pythonhosted.org/packages/2b/ae/c1b22d4524b0e10da2f29a176fb2890386f7bd1f63aacf186444873a88a0/tornado-6.4.2-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:932d195ca9015956fa502c6b56af9eb06106140d844a335590c1ec7f5277d10c", size = 437261 }, + { url = "https://files.pythonhosted.org/packages/b5/25/36dbd49ab6d179bcfc4c6c093a51795a4f3bed380543a8242ac3517a1751/tornado-6.4.2-cp38-abi3-win32.whl", hash = "sha256:2876cef82e6c5978fde1e0d5b1f919d756968d5b4282418f3146b79b58556482", size = 438463 }, + { url = "https://files.pythonhosted.org/packages/61/cc/58b1adeb1bb46228442081e746fcdbc4540905c87e8add7c277540934edb/tornado-6.4.2-cp38-abi3-win_amd64.whl", hash = "sha256:908b71bf3ff37d81073356a5fadcc660eb10c1476ee6e2725588626ce7e5ca38", size = 438907 }, +] + +[[package]] +name = "traitlets" +version = "5.14.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/eb/79/72064e6a701c2183016abbbfedaba506d81e30e232a68c9f0d6f6fcd1574/traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7", size = 161621 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size = 85359 }, +] + +[[package]] +name = "wcwidth" +version = "0.2.13" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6c/63/53559446a878410fc5a5974feb13d31d78d752eb18aeba59c7fef1af7598/wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5", size = 101301 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859", size = 34166 }, +] From 7cbf899061df01e27e183eb6cc712181411524b5 Mon Sep 17 00:00:00 2001 From: Nick Chomey Date: Tue, 11 Mar 2025 10:33:17 -0600 Subject: [PATCH 23/28] update versions, translate 26-31 --- 01_string_input_print.ipynb | 2 +- 02_variables.ipynb | 2 +- 03_list_if_in_else.ipynb | 2 +- 04_list_append_remove.ipynb | 2 +- 05_list_index_pop_insert.ipynb | 252 +++---- 06_list_slicing.ipynb | 596 ++++++++-------- 07_list_slicing_use.ipynb | 578 +++++++-------- 08_for_range.ipynb | 300 ++++---- 09_for_loop_if_equals.ipynb | 246 +++---- 10_for_search.ipynb | 444 ++++++------ 11_for_change_list.ipynb | 186 ++--- 12_for_create_list.ipynb | 212 +++--- 13_numbers.ipynb | 2 +- 15_random.ipynb | 240 +++---- 16_intro_to_algos.ipynb | 438 ++++++------ 17_while_loop.ipynb | 154 ++-- 18_while_conditions.ipynb | 368 +++++----- 19_combining_conditions.ipynb | 532 +++++++------- 20_booleans.ipynb | 610 ++++++++-------- 22_for_overview.ipynb | 16 +- 23_list_of_lists.ipynb | 2 +- 25_dictionary_list.ipynb | 2 +- 26_dictionary_use.ipynb | 552 +++++++------- 27_strings_overview.ipynb | 1224 ++++++++++++++++---------------- 28_function_inputs.ipynb | 568 +++++++-------- 29_function_outputs.ipynb | 592 +++++++-------- 30_function_io_extra.ipynb | 454 ++++++------ 31_recursion.ipynb | 68 +- 28 files changed, 4322 insertions(+), 4322 deletions(-) diff --git a/01_string_input_print.ipynb b/01_string_input_print.ipynb index a7fe4e2..60c0d08 100644 --- a/01_string_input_print.ipynb +++ b/01_string_input_print.ipynb @@ -126,7 +126,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/02_variables.ipynb b/02_variables.ipynb index b61ac4d..bb548f6 100644 --- a/02_variables.ipynb +++ b/02_variables.ipynb @@ -128,7 +128,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/03_list_if_in_else.ipynb b/03_list_if_in_else.ipynb index 632a9d9..3e45158 100644 --- a/03_list_if_in_else.ipynb +++ b/03_list_if_in_else.ipynb @@ -90,7 +90,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/04_list_append_remove.ipynb b/04_list_append_remove.ipynb index dbc6b3f..71c5112 100644 --- a/04_list_append_remove.ipynb +++ b/04_list_append_remove.ipynb @@ -104,7 +104,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/05_list_index_pop_insert.ipynb b/05_list_index_pop_insert.ipynb index e6aa959..f387be5 100644 --- a/05_list_index_pop_insert.ipynb +++ b/05_list_index_pop_insert.ipynb @@ -1,127 +1,127 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 5. Personalizando el menú\n", - "\n", - "## Métodos de lista: `.index()`, `.pop()` e `.insert()`\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estás en la cooperativa de la escuela listo para ordenar. El menú de hoy incluye una hamburguesa, una guarnición y una bebida:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu_del_dia = [\"hamburguesa\", \"ensalada\", \"coca cola\"]\n", - "print(menu_del_dia)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estás contento con la hamburguesa y la coca, pero quieres cambiar tu guarnición de *ensalada* a *papas fritas*. Para hacerlo, sigues estos pasos:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. Observa la posición de la guarnición en el menú:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "indice_guarnicion = menu_del_dia.index(\"ensalada\")\n", - "print (indice_guarnicion)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Elimina *ensalada* de la posición de la guarnición:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu_del_dia.pop(indice_guarnicion)\n", - "print (menu_del_dia)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Añade papas fritas a la posición de la guarnición:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu_del_dia.insert(indice_guarnicion, \"papas fritas\")\n", - "print (menu_del_dia)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 5. Personalizando el menú\n", + "\n", + "## Métodos de lista: `.index()`, `.pop()` e `.insert()`\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estás en la cooperativa de la escuela listo para ordenar. El menú de hoy incluye una hamburguesa, una guarnición y una bebida:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "menu_del_dia = [\"hamburguesa\", \"ensalada\", \"coca cola\"]\n", + "print(menu_del_dia)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estás contento con la hamburguesa y la coca, pero quieres cambiar tu guarnición de *ensalada* a *papas fritas*. Para hacerlo, sigues estos pasos:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Observa la posición de la guarnición en el menú:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "indice_guarnicion = menu_del_dia.index(\"ensalada\")\n", + "print (indice_guarnicion)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2. Elimina *ensalada* de la posición de la guarnición:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "menu_del_dia.pop(indice_guarnicion)\n", + "print (menu_del_dia)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3. Añade papas fritas a la posición de la guarnición:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "menu_del_dia.insert(indice_guarnicion, \"papas fritas\")\n", + "print (menu_del_dia)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/06_list_slicing.ipynb b/06_list_slicing.ipynb index 682856b..f4f4064 100644 --- a/06_list_slicing.ipynb +++ b/06_list_slicing.ipynb @@ -1,299 +1,299 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 6. Viajando por todo el mundo\n", - "\n", - "## Segmentación de listas\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Considera la siguiente lista:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ciudades = [\"San Diego\", \"Praga\", \"Ciudad del Cabo\", \"Tokio\", \"Melbourne\"]\n", - "print(ciudades)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. Segmenta \"Praga\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[1])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Segmenta las ciudades desde \"Praga\" hasta \"Tokio\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[1:4])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Segmenta \"Praga\" y \"Tokio\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[1:4:2])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. Segmenta las ciudades desde \"San Diego\" hasta \"Ciudad del Cabo\" (dos formas):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[0:3])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[:3])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "5. Segmenta las ciudades desde \"Ciudad del Cabo\" hasta \"Melbourne\" (dos formas):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[2:5])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[2:])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "6. Segmenta \"San Diego\", \"Ciudad del Cabo\" y \"Melbourne\" (cuatro formas):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[0:5:2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[0::2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[:5:2])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[::2])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "7. Segmenta \"Melbourne\" (dos formas):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[4])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[-1])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "8. Segmenta las ciudades desde \"Praga\" hasta \"Tokio\" usando índices negativos (alternativa al ejemplo 2):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[-4:-1])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "9. Segmenta las ciudades desde \"Tokio\" hasta \"Praga\" en orden inverso usando índices positivos:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ciudades[3:0:-1]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "10. Segmenta las ciudades desde \"Tokio\" hasta \"Praga\" en orden inverso usando índices negativos (alternativa al ejemplo 9):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ciudades[-2:-5:-1]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "11. Segmenta todas las ciudades en orden inverso:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (ciudades[::-1])" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 6. Viajando por todo el mundo\n", + "\n", + "## Segmentación de listas\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Considera la siguiente lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ciudades = [\"San Diego\", \"Praga\", \"Ciudad del Cabo\", \"Tokio\", \"Melbourne\"]\n", + "print(ciudades)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Segmenta \"Praga\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[1])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2. Segmenta las ciudades desde \"Praga\" hasta \"Tokio\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[1:4])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3. Segmenta \"Praga\" y \"Tokio\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[1:4:2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4. Segmenta las ciudades desde \"San Diego\" hasta \"Ciudad del Cabo\" (dos formas):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[0:3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[:3])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "5. Segmenta las ciudades desde \"Ciudad del Cabo\" hasta \"Melbourne\" (dos formas):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[2:5])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[2:])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "6. Segmenta \"San Diego\", \"Ciudad del Cabo\" y \"Melbourne\" (cuatro formas):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[0:5:2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[0::2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[:5:2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[::2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "7. Segmenta \"Melbourne\" (dos formas):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[4])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[-1])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "8. Segmenta las ciudades desde \"Praga\" hasta \"Tokio\" usando índices negativos (alternativa al ejemplo 2):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[-4:-1])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "9. Segmenta las ciudades desde \"Tokio\" hasta \"Praga\" en orden inverso usando índices positivos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ciudades[3:0:-1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "10. Segmenta las ciudades desde \"Tokio\" hasta \"Praga\" en orden inverso usando índices negativos (alternativa al ejemplo 9):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ciudades[-2:-5:-1]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "11. Segmenta todas las ciudades en orden inverso:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (ciudades[::-1])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/07_list_slicing_use.ipynb b/07_list_slicing_use.ipynb index b62ea47..6de46d1 100644 --- a/07_list_slicing_use.ipynb +++ b/07_list_slicing_use.ipynb @@ -1,290 +1,290 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7. Sentidos, planetas y una casa\n", - "\n", - "## Cambiar, añadir y eliminar elementos de una lista usando segmentación\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 1. Sentidos" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Dada la siguiente lista:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sentidos = [\"ojos\", \"nariz\", \"oídos\", \"lengua\", \"piel\"]\n", - "print(sentidos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Reemplaza \"nariz\" con \"olfato\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sentidos[1] = \"olfato\"\n", - "print (sentidos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Reemplaza \"lengua\" y \"piel\" con \"gusto\" y \"tacto\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sentidos[3:5] = [\"gusto\", \"tacto\"]\n", - "print (sentidos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Reemplaza \"ojos\" y \"oídos\" con \"vista\" y \"audición\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sentidos[0:3:2] = [\"vista\", \"audición\"]\n", - "print (sentidos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 2. Planetas" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Dada la siguiente lista:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "planetas = [\"Mercurio\", \"Marte\", \"Tierra\", \"Neptuno\"]\n", - "print(planetas)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Añade \"Júpiter\" al final de la lista:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "planetas = planetas + [\"Júpiter\"]\n", - "print (planetas)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Añade \"Venus\" entre \"Marte\" y \"Tierra\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "planetas = planetas[0:2] + [\"Venus\"] + planetas[2:5]\n", - "print (planetas)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Añade \"Urano\" y \"Saturno\" entre \"Neptuno\" y \"Júpiter\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "planetas = planetas[:5] + [\"Urano\", \"Saturno\"] + planetas[5:]\n", - "print(planetas)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 3. Una casa" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Dada la siguiente lista:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "casa = [\"cocina\", \"comedor\", \"sala\", \"dormitorio\", \"baño\", \"jardín\", \"balcón\", \"terraza\"]\n", - "print(casa)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Elimina \"comedor\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "del casa[1]\n", - "print (casa)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Elimina \"jardín\" y \"balcón\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "del casa[4:6]\n", - "print (casa)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Elimina \"cocina\", \"dormitorio\" y \"terraza\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "del casa[::2]\n", - "print (casa)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Delete \"house\":" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "del casa\n", - "print (casa)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 7. Sentidos, planetas y una casa\n", + "\n", + "## Cambiar, añadir y eliminar elementos de una lista usando segmentación\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 1. Sentidos" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sentidos = [\"ojos\", \"nariz\", \"oídos\", \"lengua\", \"piel\"]\n", + "print(sentidos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Reemplaza \"nariz\" con \"olfato\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sentidos[1] = \"olfato\"\n", + "print (sentidos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Reemplaza \"lengua\" y \"piel\" con \"gusto\" y \"tacto\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sentidos[3:5] = [\"gusto\", \"tacto\"]\n", + "print (sentidos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Reemplaza \"ojos\" y \"oídos\" con \"vista\" y \"audición\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sentidos[0:3:2] = [\"vista\", \"audición\"]\n", + "print (sentidos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. Planetas" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "planetas = [\"Mercurio\", \"Marte\", \"Tierra\", \"Neptuno\"]\n", + "print(planetas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Añade \"Júpiter\" al final de la lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "planetas = planetas + [\"Júpiter\"]\n", + "print (planetas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Añade \"Venus\" entre \"Marte\" y \"Tierra\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "planetas = planetas[0:2] + [\"Venus\"] + planetas[2:5]\n", + "print (planetas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Añade \"Urano\" y \"Saturno\" entre \"Neptuno\" y \"Júpiter\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "planetas = planetas[:5] + [\"Urano\", \"Saturno\"] + planetas[5:]\n", + "print(planetas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 3. Una casa" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "casa = [\"cocina\", \"comedor\", \"sala\", \"dormitorio\", \"baño\", \"jardín\", \"balcón\", \"terraza\"]\n", + "print(casa)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Elimina \"comedor\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "del casa[1]\n", + "print (casa)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Elimina \"jardín\" y \"balcón\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "del casa[4:6]\n", + "print (casa)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Elimina \"cocina\", \"dormitorio\" y \"terraza\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "del casa[::2]\n", + "print (casa)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Delete \"house\":" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "del casa\n", + "print (casa)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/08_for_range.ipynb b/08_for_range.ipynb index 5bc9875..ec450ec 100644 --- a/08_for_range.ipynb +++ b/08_for_range.ipynb @@ -1,151 +1,151 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 8. Los platillos favoritos de mis amigos\n", - "\n", - "## `for` ... `in` `range()`\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Aquí tienes una lista de mis amigos y una lista de sus platillos favoritos:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "amigos = [\"Carlos\", \"Ian\", \"Fernando\", \"Amelia\"]\n", - "platillos = [\"tacos al pastor\", \"tortas\", \"chilaquiles\", \"enchiladas\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estos son todos mis amigos:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Los nombres de mis amigos son:\")\n", - "print(amigos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estos son mis amigos uno por uno:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for indice in range (0,4):\n", - " print (\"Índice: \" + str(indice))\n", - " print (\"Amigo: \" + amigos[indice])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estos son todos sus platillos favoritos:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Sus platillos favoritos son:\")\n", - "print(platillos)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estos son sus platillos favoritos uno por uno:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for indice in range(0, 4):\n", - " print(\"Índice: \" + str(indice))\n", - " print(\"Platillo: \" + platillos[indice])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estos son mis amigos, con sus platillos favoritos uno por uno:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for indice in range(0, 4):\n", - " print(\"El platillo favorito de \" + amigos[indice] + \" son \" + platillos[indice])" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 8. Los platillos favoritos de mis amigos\n", + "\n", + "## `for` ... `in` `range()`\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Aquí tienes una lista de mis amigos y una lista de sus platillos favoritos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "amigos = [\"Carlos\", \"Ian\", \"Fernando\", \"Amelia\"]\n", + "platillos = [\"tacos al pastor\", \"tortas\", \"chilaquiles\", \"enchiladas\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estos son todos mis amigos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Los nombres de mis amigos son:\")\n", + "print(amigos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estos son mis amigos uno por uno:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for indice in range (0,4):\n", + " print (\"Índice: \" + str(indice))\n", + " print (\"Amigo: \" + amigos[indice])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estos son todos sus platillos favoritos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(\"Sus platillos favoritos son:\")\n", + "print(platillos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estos son sus platillos favoritos uno por uno:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for indice in range(0, 4):\n", + " print(\"Índice: \" + str(indice))\n", + " print(\"Platillo: \" + platillos[indice])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estos son mis amigos, con sus platillos favoritos uno por uno:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for indice in range(0, 4):\n", + " print(\"El platillo favorito de \" + amigos[indice] + \" son \" + platillos[indice])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/09_for_loop_if_equals.ipynb b/09_for_loop_if_equals.ipynb index 834061c..bd2a504 100644 --- a/09_for_loop_if_equals.ipynb +++ b/09_for_loop_if_equals.ipynb @@ -1,124 +1,124 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9. En el zoológico\n", - "## Bucle `for` con `if`... `==` ... / `else`\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Estás en el zoológico y anotas una lista de algunos animales que ves:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "animales = [\"elefante\", \"pingüino\", \"delfín\"]\n", - "print(animales)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Luego imprimes los animales uno por uno:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(0, len(animales)):\n", - " print(\"-- Inicio del bucle --\")\n", - " # Imprime cada elemento y su posición\n", - " print(\"El elemento en la posición \" + str(i) + \" es \" + animales[i])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Realmente querías ver un pingüino:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "querias_ver = \"pingüino\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Una vez en casa, le cuentas a tu amigo los animales que viste, especificando cuál de ellos realmente querías ver:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(0, len(animales)):\n", - " # Si el animal actual es el que realmente querías ver\n", - " if animales[i] == querias_ver:\n", - " # Imprime que viste ese animal y que realmente querías verlo\n", - " print(\"Vi un \" + animales[i] + \" y realmente quería verlo\")\n", - " # Si el animal actual no es el que realmente querías ver\n", - " else:\n", - " # Simplemente imprime que lo viste\n", - " print(\"Vi un \" + animales[i])\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 9. En el zoológico\n", + "## Bucle `for` con `if`... `==` ... / `else`\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Estás en el zoológico y anotas una lista de algunos animales que ves:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "animales = [\"elefante\", \"pingüino\", \"delfín\"]\n", + "print(animales)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Luego imprimes los animales uno por uno:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(0, len(animales)):\n", + " print(\"-- Inicio del bucle --\")\n", + " # Imprime cada elemento y su posición\n", + " print(\"El elemento en la posición \" + str(i) + \" es \" + animales[i])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Realmente querías ver un pingüino:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "querias_ver = \"pingüino\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Una vez en casa, le cuentas a tu amigo los animales que viste, especificando cuál de ellos realmente querías ver:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(0, len(animales)):\n", + " # Si el animal actual es el que realmente querías ver\n", + " if animales[i] == querias_ver:\n", + " # Imprime que viste ese animal y que realmente querías verlo\n", + " print(\"Vi un \" + animales[i] + \" y realmente quería verlo\")\n", + " # Si el animal actual no es el que realmente querías ver\n", + " else:\n", + " # Simplemente imprime que lo viste\n", + " print(\"Vi un \" + animales[i])\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/10_for_search.ipynb b/10_for_search.ipynb index 010138b..9bbb7d8 100644 --- a/10_for_search.ipynb +++ b/10_for_search.ipynb @@ -1,223 +1,223 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 10. ¿Dónde están mis guantes?\n", - "\n", - "## Bucle `for` para buscar\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Quién no tiene un cajón desordenado? ¡Aquí está el nuestro! Contiene algunos accesorios:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "accesorios = [\"cinturón\", \"gorra\", \"guantes\", \"lentes oscuros\", \"anillo\"]\n", - "print(accesorios)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Imprime todos los accesorios uno por uno, junto con sus posiciones en la lista. Usa una frase como *El elemento x está en la posición y*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Imprime cada elemento y su posición\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. Imprime el accesorio cuyo nombre **está compuesto por** 8 caracteres y su posición en la lista. Utiliza una frase como *El elemento x está en la posición y y tiene n caracteres*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la longitud del elemento es igual a 8\n", - " if len(accesorios[i]) == 8:\n", - " # Imprime el elemento, su posición y su número de caracteres\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene 8 caracteres.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Imprime los accesorios cuyos nombres están compuestos por **menos de** 8 caracteres:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la longitud del elemento es menor que 8\n", - " if len(accesorios[i]) < 8:\n", - " # Imprime el elemento, su posición y que tiene menos de 8 caracteres\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene menos de 8 caracteres.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Imprime los accesorios cuyos nombres están compuestos por **más de** 8 caracteres. Además, asigna 8 a una variable:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Definiendo el umbral\n", - "n_de_caracteres = 8\n", - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la longitud del elemento es mayor que el umbral\n", - " if len(accesorios[i]) > n_de_caracteres:\n", - " # Imprime el elemento, su posición y que tiene más de n_de_caracteres caracteres\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene más de \" + str(n_de_caracteres) + \" caracteres.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. Imprime los accesorios cuyos nombres están compuestos por un número de caracteres **diferente de** 8:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# Definiendo el umbral\n", - "n_de_caracteres = 8\n", - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la longitud del elemento no es igual al umbral\n", - " if len(accesorios[i]) != n_de_caracteres:\n", - " # Imprime el elemento, su posición y que tiene un número de caracteres diferente de n_de_caracteres\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene un número de caracteres diferente de \" + str(n_de_caracteres) + \".\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "5. Imprime los accesorios cuya posición es **menor o igual a** 2:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# Definiendo el umbral\n", - "posicion_umbral = 2\n", - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la posición del elemento es menor o igual al umbral\n", - " if i <= posicion_umbral:\n", - " # Imprime el elemento, su posición y que la posición es menor o igual a la posición_umbral\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \", que es menor o igual a \" + str(posicion_umbral) + \".\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "6. Imprime los accesorios cuya posición es **al menos** 2:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# Definiendo el umbral\n", - "posicion_umbral = 2\n", - "# Para cada posición en la lista\n", - "for i in range(len(accesorios)):\n", - " # Si la posición del elemento es mayor o igual al umbral\n", - " if i >= posicion_umbral:\n", - " # Imprime el elemento, su posición y que la posición es al menos la posición_umbral\n", - " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \", que es al menos \" + str(posicion_umbral) + \".\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 10. ¿Dónde están mis guantes?\n", + "\n", + "## Bucle `for` para buscar\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Quién no tiene un cajón desordenado? ¡Aquí está el nuestro! Contiene algunos accesorios:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "accesorios = [\"cinturón\", \"gorra\", \"guantes\", \"lentes oscuros\", \"anillo\"]\n", + "print(accesorios)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime todos los accesorios uno por uno, junto con sus posiciones en la lista. Usa una frase como *El elemento x está en la posición y*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Imprime cada elemento y su posición\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1. Imprime el accesorio cuyo nombre **está compuesto por** 8 caracteres y su posición en la lista. Utiliza una frase como *El elemento x está en la posición y y tiene n caracteres*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la longitud del elemento es igual a 8\n", + " if len(accesorios[i]) == 8:\n", + " # Imprime el elemento, su posición y su número de caracteres\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene 8 caracteres.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2. Imprime los accesorios cuyos nombres están compuestos por **menos de** 8 caracteres:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la longitud del elemento es menor que 8\n", + " if len(accesorios[i]) < 8:\n", + " # Imprime el elemento, su posición y que tiene menos de 8 caracteres\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene menos de 8 caracteres.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3. Imprime los accesorios cuyos nombres están compuestos por **más de** 8 caracteres. Además, asigna 8 a una variable:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Definiendo el umbral\n", + "n_de_caracteres = 8\n", + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la longitud del elemento es mayor que el umbral\n", + " if len(accesorios[i]) > n_de_caracteres:\n", + " # Imprime el elemento, su posición y que tiene más de n_de_caracteres caracteres\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene más de \" + str(n_de_caracteres) + \" caracteres.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4. Imprime los accesorios cuyos nombres están compuestos por un número de caracteres **diferente de** 8:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Definiendo el umbral\n", + "n_de_caracteres = 8\n", + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la longitud del elemento no es igual al umbral\n", + " if len(accesorios[i]) != n_de_caracteres:\n", + " # Imprime el elemento, su posición y que tiene un número de caracteres diferente de n_de_caracteres\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \" y tiene un número de caracteres diferente de \" + str(n_de_caracteres) + \".\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "5. Imprime los accesorios cuya posición es **menor o igual a** 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Definiendo el umbral\n", + "posicion_umbral = 2\n", + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la posición del elemento es menor o igual al umbral\n", + " if i <= posicion_umbral:\n", + " # Imprime el elemento, su posición y que la posición es menor o igual a la posición_umbral\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \", que es menor o igual a \" + str(posicion_umbral) + \".\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "6. Imprime los accesorios cuya posición es **al menos** 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Definiendo el umbral\n", + "posicion_umbral = 2\n", + "# Para cada posición en la lista\n", + "for i in range(len(accesorios)):\n", + " # Si la posición del elemento es mayor o igual al umbral\n", + " if i >= posicion_umbral:\n", + " # Imprime el elemento, su posición y que la posición es al menos la posición_umbral\n", + " print(\"El elemento \" + accesorios[i] + \" está en la posición \" + str(i) + \", que es al menos \" + str(posicion_umbral) + \".\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/11_for_change_list.ipynb b/11_for_change_list.ipynb index d3923df..b620ac4 100644 --- a/11_for_change_list.ipynb +++ b/11_for_change_list.ipynb @@ -1,94 +1,94 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 11. Limpiando la lista de correo\n", - "\n", - "## Bucle `for` para cambiar elementos de la lista\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Eres responsable de un boletín informativo y debes enviar un correo electrónico a las siguientes direcciones:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "email = [\"SARAH.BROWN@GMAIL.com\", \"Pablo.Hernandez@live.com\", \"LI.Min@hotmail.com\"] " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Por cuestiones de consistencia, deseas que todas las direcciones de correo electrónico estén en minúsculas. Por lo tanto, las cambias:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(0, len(email)):\n", - " \n", - " print(\"-> Bucle: \" + str(i))\n", - " \n", - " # Imprime el elemento antes del cambio\n", - " print(\"Antes del cambio, el elemento en la posición \" + str(i) + \" es: \" + email[i])\n", - " \n", - " # Cambia el elemento y reasigna\n", - " email[i] = email[i].lower()\n", - " \n", - " # Imprime el elemento después del cambio\n", - " print(\"Después del cambio, el elemento en la posición \" + str(i) + \" es: \" + email[i])\n", - " \n", - "# Imprime la lista modificada\n", - "print(\"Ahora la lista es: \" + str(email))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 11. Limpiando la lista de correo\n", + "\n", + "## Bucle `for` para cambiar elementos de la lista\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Eres responsable de un boletín informativo y debes enviar un correo electrónico a las siguientes direcciones:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "email = [\"SARAH.BROWN@GMAIL.com\", \"Pablo.Hernandez@live.com\", \"LI.Min@hotmail.com\"] " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Por cuestiones de consistencia, deseas que todas las direcciones de correo electrónico estén en minúsculas. Por lo tanto, las cambias:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(0, len(email)):\n", + " \n", + " print(\"-> Bucle: \" + str(i))\n", + " \n", + " # Imprime el elemento antes del cambio\n", + " print(\"Antes del cambio, el elemento en la posición \" + str(i) + \" es: \" + email[i])\n", + " \n", + " # Cambia el elemento y reasigna\n", + " email[i] = email[i].lower()\n", + " \n", + " # Imprime el elemento después del cambio\n", + " print(\"Después del cambio, el elemento en la posición \" + str(i) + \" es: \" + email[i])\n", + " \n", + "# Imprime la lista modificada\n", + "print(\"Ahora la lista es: \" + str(email))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/12_for_create_list.ipynb b/12_for_create_list.ipynb index 2d4c456..9abecd1 100644 --- a/12_for_create_list.ipynb +++ b/12_for_create_list.ipynb @@ -1,107 +1,107 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 12. ¡Qué desorden en la librería!\n", - "\n", - "## Bucle `for` para crear nuevas listas\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Hoy había muchos clientes en la tienda, y mezclaron los libros cuyos autores tienen apellidos que empiezan con A y S:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "autores = [\"Alcott\", \"Saint-Exupery\", \"Arendt\", \"Sepúlveda\", \"Shakespeare\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Así que debes colocar los libros cuyos autores tienen apellidos que comienzan con A en un estante y los libros cuyos autores tienen apellidos que comienzan con S en otro estante:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Inicializa las variables como listas vacías\n", - "estante_a = []\n", - "estante_s = []\n", - "\n", - "# Para cada posición en la lista\n", - "for i in range(len(autores)):\n", - " \n", - " # Imprime el autor actual\n", - " print(\"El autor actual es: \" + autores[i])\n", - " \n", - " # Obtiene la inicial del autor actual\n", - " inicial_autor = autores[i][0]\n", - " print(\"La inicial del autor es: \" + inicial_autor)\n", - " \n", - " # Si la inicial del autor es A\n", - " if inicial_autor == \"A\":\n", - " # Agrega el autor al estante A\n", - " estante_a.append(autores[i])\n", - " print(\"El estante A ahora contiene: \" + str(estante_a) + \"\\n\")\n", - " \n", - " # En caso contrario (la inicial del autor no es A)\n", - " else:\n", - " # Agrega el autor al estante S\n", - " estante_s = estante_s + [autores[i]]\n", - " print(\"El estante S ahora contiene: \" + str(estante_s) + \"\\n\")\n", - "\n", - "# Imprime los estantes finales\n", - "print(\"Los autores en el estante A son: \" + str(estante_a))\n", - "print(\"Los autores en el estante S son: \" + str(estante_s))\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 12. ¡Qué desorden en la librería!\n", + "\n", + "## Bucle `for` para crear nuevas listas\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Hoy había muchos clientes en la tienda, y mezclaron los libros cuyos autores tienen apellidos que empiezan con A y S:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "autores = [\"Alcott\", \"Saint-Exupery\", \"Arendt\", \"Sepúlveda\", \"Shakespeare\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Así que debes colocar los libros cuyos autores tienen apellidos que comienzan con A en un estante y los libros cuyos autores tienen apellidos que comienzan con S en otro estante:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inicializa las variables como listas vacías\n", + "estante_a = []\n", + "estante_s = []\n", + "\n", + "# Para cada posición en la lista\n", + "for i in range(len(autores)):\n", + " \n", + " # Imprime el autor actual\n", + " print(\"El autor actual es: \" + autores[i])\n", + " \n", + " # Obtiene la inicial del autor actual\n", + " inicial_autor = autores[i][0]\n", + " print(\"La inicial del autor es: \" + inicial_autor)\n", + " \n", + " # Si la inicial del autor es A\n", + " if inicial_autor == \"A\":\n", + " # Agrega el autor al estante A\n", + " estante_a.append(autores[i])\n", + " print(\"El estante A ahora contiene: \" + str(estante_a) + \"\\n\")\n", + " \n", + " # En caso contrario (la inicial del autor no es A)\n", + " else:\n", + " # Agrega el autor al estante S\n", + " estante_s = estante_s + [autores[i]]\n", + " print(\"El estante S ahora contiene: \" + str(estante_s) + \"\\n\")\n", + "\n", + "# Imprime los estantes finales\n", + "print(\"Los autores en el estante A son: \" + str(estante_a))\n", + "print(\"Los autores en el estante S son: \" + str(estante_s))\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/13_numbers.ipynb b/13_numbers.ipynb index 59e8756..b8c2d64 100644 --- a/13_numbers.ipynb +++ b/13_numbers.ipynb @@ -403,7 +403,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/15_random.ipynb b/15_random.ipynb index cfb21ec..6405e62 100644 --- a/15_random.ipynb +++ b/15_random.ipynb @@ -1,121 +1,121 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 15. Galletas de la suerte\n", - "\n", - "## El módulo de Python *random*\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Te encuentras en un restaurante chino, y al final de la comida, te dan una galleta de la suerte. Solo quedan tres galletas de la suerte. Cada una de ellas contiene un mensaje:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "galletas_suerte = [\"El hombre en la cima de la montaña no cayó allí\",\n", - " \"Si viene el invierno, ¿puede estar lejos la primavera?\",\n", - " \"La tierra siempre está en la mente de un pájaro volador\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Qué galleta de la suerte obtendrás? ¡Deja que la computadora decida! Para hacerlo, la computadora necesita un módulo llamado random:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Aquí tienes tu mensaje cuando la computadora elige un índice del mensaje:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Elije un índice del mensaje\n", - "indice_mensaje = random.randint(0, len(galletas_suerte) - 1)\n", - "print(\"Índice del mensaje:\", indice_mensaje)\n", - "\n", - "# Obtiene el mensaje\n", - "mensaje = galletas_suerte[indice_mensaje]\n", - "print(\"Mensaje de la galleta de la suerte:\", mensaje)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Y aquí está tu mensaje cuando la computadora elige directamente un mensaje:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Elije un mensaje\n", - "mensaje = random.choice(galletas_suerte)\n", - "print(\"Mensaje de la galleta de la suerte:\", mensaje)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 15. Galletas de la suerte\n", + "\n", + "## El módulo de Python *random*\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Te encuentras en un restaurante chino, y al final de la comida, te dan una galleta de la suerte. Solo quedan tres galletas de la suerte. Cada una de ellas contiene un mensaje:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "galletas_suerte = [\"El hombre en la cima de la montaña no cayó allí\",\n", + " \"Si viene el invierno, ¿puede estar lejos la primavera?\",\n", + " \"La tierra siempre está en la mente de un pájaro volador\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Qué galleta de la suerte obtendrás? ¡Deja que la computadora decida! Para hacerlo, la computadora necesita un módulo llamado random:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Aquí tienes tu mensaje cuando la computadora elige un índice del mensaje:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Elije un índice del mensaje\n", + "indice_mensaje = random.randint(0, len(galletas_suerte) - 1)\n", + "print(\"Índice del mensaje:\", indice_mensaje)\n", + "\n", + "# Obtiene el mensaje\n", + "mensaje = galletas_suerte[indice_mensaje]\n", + "print(\"Mensaje de la galleta de la suerte:\", mensaje)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Y aquí está tu mensaje cuando la computadora elige directamente un mensaje:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Elije un mensaje\n", + "mensaje = random.choice(galletas_suerte)\n", + "print(\"Mensaje de la galleta de la suerte:\", mensaje)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/16_intro_to_algos.ipynb b/16_intro_to_algos.ipynb index 8634d26..4dce02b 100644 --- a/16_intro_to_algos.ipynb +++ b/16_intro_to_algos.ipynb @@ -1,220 +1,220 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 16. Piedra, papel, tijeras\n", - "\n", - "## Introducción a los algoritmos\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 1. Elección de la computadora\n", - "- Haz que la computadora elija entre *piedra*, *papel* o *tijeras*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "# Lista de posibilidades del juego\n", - "posibilidades = [\"piedra\", \"papel\", \"tijeras\"]\n", - "\n", - "# Elección aleatoria de la computadora\n", - "eleccion_computadora = random.choice(posibilidades)\n", - "print(eleccion_computadora)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2. Elección del jugador\n", - "- Haz que el jugador elija entre *piedra*, *papel* o *tijeras*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Pidiendo al jugador que haga su elección\n", - "eleccion_jugador = input(\"Piedra, papel o tijeras?\")\n", - "print(eleccion_jugador)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3. Determina quién gana\n", - "- Si la computadora elige *piedra*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if eleccion_computadora == \"piedra\":\n", - "\n", - " # compara con la elección del jugador\n", - " if eleccion_jugador == \"piedra\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"papel\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"¡La computadora gana!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Si la computadora elige *papel*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if eleccion_computadora == \"papel\":\n", - "\n", - " # compara con la elección del jugador\n", - " if eleccion_jugador == \"papel\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"tijeras\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"¡La computadora gana!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Si la computadora elige *tijeras*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if eleccion_computadora == \"tijeras\":\n", - "\n", - " # compara con la elección del jugador\n", - " if eleccion_jugador == \"tijeras\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"piedra\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"No ganaste\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Combinando el código\n", - "- Vamos a combinar el código:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "# Lista de posibilidades del juego\n", - "posibilidades = [\"piedra\", \"papel\", \"tijeras\"]\n", - "\n", - "# Elección aleatoria de la computadora\n", - "eleccion_computadora = random.choice(posibilidades)\n", - "\n", - "# Elección del jugador\n", - "eleccion_jugador = input(\"Piedra, papel o tijeras?\")\n", - "\n", - "# Determinar quién gana\n", - "# Si la computadora elige piedra\n", - "if eleccion_computadora == \"piedra\":\n", - " # Compara con la elección del jugador\n", - " if eleccion_jugador == \"piedra\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"papel\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"¡La computadora gana!\")\n", - "\n", - "# Si la computadora elige papel\n", - "if eleccion_computadora == \"papel\":\n", - " # Compara con la elección del jugador\n", - " if eleccion_jugador == \"papel\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"tijeras\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"¡La computadora gana!\")\n", - "\n", - "# Si la computadora elige tijeras\n", - "if eleccion_computadora == \"tijeras\":\n", - " # Compara con la elección del jugador\n", - " if eleccion_jugador == \"tijeras\":\n", - " print(\"¡Empate!\")\n", - " elif eleccion_jugador == \"piedra\":\n", - " print(\"¡Tú ganas!\")\n", - " else:\n", - " print(\"No ganaste\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 16. Piedra, papel, tijeras\n", + "\n", + "## Introducción a los algoritmos\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1. Elección de la computadora\n", + "- Haz que la computadora elija entre *piedra*, *papel* o *tijeras*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Lista de posibilidades del juego\n", + "posibilidades = [\"piedra\", \"papel\", \"tijeras\"]\n", + "\n", + "# Elección aleatoria de la computadora\n", + "eleccion_computadora = random.choice(posibilidades)\n", + "print(eleccion_computadora)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2. Elección del jugador\n", + "- Haz que el jugador elija entre *piedra*, *papel* o *tijeras*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Pidiendo al jugador que haga su elección\n", + "eleccion_jugador = input(\"Piedra, papel o tijeras?\")\n", + "print(eleccion_jugador)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3. Determina quién gana\n", + "- Si la computadora elige *piedra*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if eleccion_computadora == \"piedra\":\n", + "\n", + " # compara con la elección del jugador\n", + " if eleccion_jugador == \"piedra\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"papel\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"¡La computadora gana!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Si la computadora elige *papel*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if eleccion_computadora == \"papel\":\n", + "\n", + " # compara con la elección del jugador\n", + " if eleccion_jugador == \"papel\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"tijeras\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"¡La computadora gana!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Si la computadora elige *tijeras*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if eleccion_computadora == \"tijeras\":\n", + "\n", + " # compara con la elección del jugador\n", + " if eleccion_jugador == \"tijeras\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"piedra\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"No ganaste\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Combinando el código\n", + "- Vamos a combinar el código:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Lista de posibilidades del juego\n", + "posibilidades = [\"piedra\", \"papel\", \"tijeras\"]\n", + "\n", + "# Elección aleatoria de la computadora\n", + "eleccion_computadora = random.choice(posibilidades)\n", + "\n", + "# Elección del jugador\n", + "eleccion_jugador = input(\"Piedra, papel o tijeras?\")\n", + "\n", + "# Determinar quién gana\n", + "# Si la computadora elige piedra\n", + "if eleccion_computadora == \"piedra\":\n", + " # Compara con la elección del jugador\n", + " if eleccion_jugador == \"piedra\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"papel\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"¡La computadora gana!\")\n", + "\n", + "# Si la computadora elige papel\n", + "if eleccion_computadora == \"papel\":\n", + " # Compara con la elección del jugador\n", + " if eleccion_jugador == \"papel\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"tijeras\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"¡La computadora gana!\")\n", + "\n", + "# Si la computadora elige tijeras\n", + "if eleccion_computadora == \"tijeras\":\n", + " # Compara con la elección del jugador\n", + " if eleccion_jugador == \"tijeras\":\n", + " print(\"¡Empate!\")\n", + " elif eleccion_jugador == \"piedra\":\n", + " print(\"¡Tú ganas!\")\n", + " else:\n", + " print(\"No ganaste\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/17_while_loop.ipynb b/17_while_loop.ipynb index 4d3b4a1..c7e865e 100644 --- a/17_while_loop.ipynb +++ b/17_while_loop.ipynb @@ -1,78 +1,78 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 17. ¿Quieres más dulces?\n", - "\n", - "## El bucle `while`\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Inicializa tus variables\n", - "cantidad_de_dulces = 0\n", - "\n", - "# Imprime la cantidad inicial de dulces que tienes\n", - "print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", - "\n", - "# Responde si deseas un dulce\n", - "respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", - "\n", - "# Mientras tu respuesta sea sí:\n", - "while respuesta == \"sí\":\n", - "\n", - " # Agrega un dulce a tu colección\n", - " cantidad_de_dulces += 1\n", - "\n", - " # Imprime la cantidad actual de dulces que tienes\n", - " print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", - "\n", - " # Pregunta de nuevo si deseas más dulces\n", - " respuesta = input(\"¿Quieres más dulces? (sí/no)\")\n", - "\n", - "# Imprime la cantidad final de dulces que tienes\n", - "print(\"Tienes un total de \" + str(cantidad_de_dulces) + \" dulces\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 17. ¿Quieres más dulces?\n", + "\n", + "## El bucle `while`\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inicializa tus variables\n", + "cantidad_de_dulces = 0\n", + "\n", + "# Imprime la cantidad inicial de dulces que tienes\n", + "print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", + "\n", + "# Responde si deseas un dulce\n", + "respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", + "\n", + "# Mientras tu respuesta sea sí:\n", + "while respuesta == \"sí\":\n", + "\n", + " # Agrega un dulce a tu colección\n", + " cantidad_de_dulces += 1\n", + "\n", + " # Imprime la cantidad actual de dulces que tienes\n", + " print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", + "\n", + " # Pregunta de nuevo si deseas más dulces\n", + " respuesta = input(\"¿Quieres más dulces? (sí/no)\")\n", + "\n", + "# Imprime la cantidad final de dulces que tienes\n", + "print(\"Tienes un total de \" + str(cantidad_de_dulces) + \" dulces\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/18_while_conditions.ipynb b/18_while_conditions.ipynb index bb83b89..d7678f0 100644 --- a/18_while_conditions.ipynb +++ b/18_while_conditions.ipynb @@ -1,185 +1,185 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 18. Animales, números únicos y suma\n", - "\n", - "## Varios tipos de condiciones\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "animales = [\"jaguar\", \"manatí\", \"colibrí\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Crea un juego en el que la computadora elija al azar uno de los tres animales y el jugador debe adivinar el animal elegido por la computadora. Asegúrate de que el jugador siga jugando hasta que adivine el animal seleccionado por la computadora. Al final del juego, dile al jugador cuántos intentos le tomó adivinar el animal." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "# Elección de la computadora\n", - "eleccion_computadora = random.choice(animales)\n", - "\n", - "# Elección del jugador\n", - "eleccion_jugador = input(\"¡Adivina el animal! Opciones: jaguar, manatí, colibrí: \")\n", - "\n", - "# Inicializar el contador de intentos\n", - "n_de_intentos = 1\n", - "\n", - "# Mientras la elección del jugador y la elección de la computadora sean diferentes\n", - "while eleccion_jugador != eleccion_computadora:\n", - "\n", - " # Informar al jugador que no es el animal correcto\n", - " print(\"¡Ese no es el animal correcto!\")\n", - "\n", - " # Imprimir el número de intentos hasta ahora\n", - " print(\"Número de intentos hasta ahora: \" + str(n_de_intentos))\n", - "\n", - " # Incrementar el número de intentos\n", - " n_de_intentos += 1\n", - "\n", - " # Pedir al jugador que adivine de nuevo\n", - " eleccion_jugador = input(\"¡Inténtalo de nuevo! Adivina el animal! Opciones: jaguar, manatí, colibrí: \")\n", - "\n", - "# Informar al jugador que adivinó el animal correcto\n", - "print(\"¡Bien hecho! Adivinaste \" + eleccion_computadora + \" en el intento número \" + str(n_de_intentos))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "---\n", - "## 2. ¡Crea una lista de 8 números aleatorios únicos!\n", - "\n", - "- Crea una lista de 8 números aleatorios entre 0 y 10. Asegúrate de que sean únicos, es decir, que cada número esté presente solo una vez en la lista. Si el número ya está en la lista, entonces imprime lo siguiente: *El número x ya está en la lista*. ¿Cuántos números generaste antes de encontrar 8 números únicos?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "# Inicializar la lista de números únicos\n", - "numeros_aleatorios_unicos = []\n", - "\n", - "# Inicializar el contador\n", - "contador = 0\n", - "\n", - "# Mientras la longitud de la lista no sea 8\n", - "while len(numeros_aleatorios_unicos) != 8:\n", - "\n", - " # Generar un número aleatorio entre 0 y 10\n", - " numero = random.randint(0, 10)\n", - "\n", - " # Incrementar el contador en 1\n", - " contador += 1\n", - "\n", - " # Si el número ya está en la lista\n", - " if numero in numeros_aleatorios_unicos:\n", - " # Imprime que el número ya está en la lista\n", - " print(\"El número \" + str(numero) + \" ya está en la lista\")\n", - " # En caso contrario\n", - " else:\n", - " # Agregar el nuevo número a la lista\n", - " numeros_aleatorios_unicos.append(numero)\n", - "\n", - "# Imprimir la lista final y el total de números generados\n", - "print(numeros_aleatorios_unicos)\n", - "print(\"El total de números generados es: \" + str(contador))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 3. Sumar múltiplos positivos de 3\n", - "\n", - "- Escribe un código que siga pidiendo a un jugador que ingrese un número entero hasta que ingresen un número negativo. Al final, imprime la suma de todos los enteros ingresados que sean múltiplos de 3." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Inicializa la suma en 0\n", - "suma_de_numeros = 0\n", - "\n", - "# Pide al usuario que ingrese un número entero\n", - "numero = int(input(\"Ingresa un número entero: \"))\n", - "\n", - "# Mientras el número sea positivo\n", - "while numero >= 0:\n", - "\n", - " # Si el número es múltiplo de 3\n", - " if numero % 3 == 0:\n", - " # Suma el número a la suma total\n", - " suma_de_numeros += numero\n", - "\n", - " # Pide el siguiente número entero\n", - " numero = int(input(\"Ingresa otro número entero: \"))\n", - "\n", - "# Imprime la suma final\n", - "print(\"La suma de los múltiplos de 3 ingresados es: \" + str(suma_de_numeros))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 18. Animales, números únicos y suma\n", + "\n", + "## Varios tipos de condiciones\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "animales = [\"jaguar\", \"manatí\", \"colibrí\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Crea un juego en el que la computadora elija al azar uno de los tres animales y el jugador debe adivinar el animal elegido por la computadora. Asegúrate de que el jugador siga jugando hasta que adivine el animal seleccionado por la computadora. Al final del juego, dile al jugador cuántos intentos le tomó adivinar el animal." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Elección de la computadora\n", + "eleccion_computadora = random.choice(animales)\n", + "\n", + "# Elección del jugador\n", + "eleccion_jugador = input(\"¡Adivina el animal! Opciones: jaguar, manatí, colibrí: \")\n", + "\n", + "# Inicializar el contador de intentos\n", + "n_de_intentos = 1\n", + "\n", + "# Mientras la elección del jugador y la elección de la computadora sean diferentes\n", + "while eleccion_jugador != eleccion_computadora:\n", + "\n", + " # Informar al jugador que no es el animal correcto\n", + " print(\"¡Ese no es el animal correcto!\")\n", + "\n", + " # Imprimir el número de intentos hasta ahora\n", + " print(\"Número de intentos hasta ahora: \" + str(n_de_intentos))\n", + "\n", + " # Incrementar el número de intentos\n", + " n_de_intentos += 1\n", + "\n", + " # Pedir al jugador que adivine de nuevo\n", + " eleccion_jugador = input(\"¡Inténtalo de nuevo! Adivina el animal! Opciones: jaguar, manatí, colibrí: \")\n", + "\n", + "# Informar al jugador que adivinó el animal correcto\n", + "print(\"¡Bien hecho! Adivinaste \" + eleccion_computadora + \" en el intento número \" + str(n_de_intentos))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "---\n", + "## 2. ¡Crea una lista de 8 números aleatorios únicos!\n", + "\n", + "- Crea una lista de 8 números aleatorios entre 0 y 10. Asegúrate de que sean únicos, es decir, que cada número esté presente solo una vez en la lista. Si el número ya está en la lista, entonces imprime lo siguiente: *El número x ya está en la lista*. ¿Cuántos números generaste antes de encontrar 8 números únicos?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Inicializar la lista de números únicos\n", + "numeros_aleatorios_unicos = []\n", + "\n", + "# Inicializar el contador\n", + "contador = 0\n", + "\n", + "# Mientras la longitud de la lista no sea 8\n", + "while len(numeros_aleatorios_unicos) != 8:\n", + "\n", + " # Generar un número aleatorio entre 0 y 10\n", + " numero = random.randint(0, 10)\n", + "\n", + " # Incrementar el contador en 1\n", + " contador += 1\n", + "\n", + " # Si el número ya está en la lista\n", + " if numero in numeros_aleatorios_unicos:\n", + " # Imprime que el número ya está en la lista\n", + " print(\"El número \" + str(numero) + \" ya está en la lista\")\n", + " # En caso contrario\n", + " else:\n", + " # Agregar el nuevo número a la lista\n", + " numeros_aleatorios_unicos.append(numero)\n", + "\n", + "# Imprimir la lista final y el total de números generados\n", + "print(numeros_aleatorios_unicos)\n", + "print(\"El total de números generados es: \" + str(contador))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 3. Sumar múltiplos positivos de 3\n", + "\n", + "- Escribe un código que siga pidiendo a un jugador que ingrese un número entero hasta que ingresen un número negativo. Al final, imprime la suma de todos los enteros ingresados que sean múltiplos de 3." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inicializa la suma en 0\n", + "suma_de_numeros = 0\n", + "\n", + "# Pide al usuario que ingrese un número entero\n", + "numero = int(input(\"Ingresa un número entero: \"))\n", + "\n", + "# Mientras el número sea positivo\n", + "while numero >= 0:\n", + "\n", + " # Si el número es múltiplo de 3\n", + " if numero % 3 == 0:\n", + " # Suma el número a la suma total\n", + " suma_de_numeros += numero\n", + "\n", + " # Pide el siguiente número entero\n", + " numero = int(input(\"Ingresa otro número entero: \"))\n", + "\n", + "# Imprime la suma final\n", + "print(\"La suma de los múltiplos de 3 ingresados es: \" + str(suma_de_numeros))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/19_combining_conditions.ipynb b/19_combining_conditions.ipynb index c160055..64c3ec9 100644 --- a/19_combining_conditions.ipynb +++ b/19_combining_conditions.ipynb @@ -1,267 +1,267 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 19. And, or, not, not in\n", - "\n", - "## Combinando y revirtiendo condiciones\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## and \n", - "\n", - "- Dada la siguiente lista de enteros:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numeros = [1, 5, 7, 2, 8, 19]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Imprime los números que están entre 5 **y** 10:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(0, len(numeros)):\n", - "\n", - " # Si el número actual está entre 5 y 10\n", - " if numeros[i] >= 5 and numeros[i] <= 10:\n", - "\n", - " # Imprime el número actual\n", - " print(\"El número \" + str(numeros[i]) + \" está entre 5 y 10\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## or \n", - "\n", - "- Dada la siguiente cadena de texto: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mensaje = \"¡¡¡Que tengas un buen día!!!\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Y dados todos los signos de puntuación:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "puntuacion = \"\\\"/\\'()[]{}<>,.;:¿?¡!^@∼#$%&*_-\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Imprime y cuenta el número de caracteres que son signos de puntuación **o** vocales:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Cadena de vocales\n", - "vocales = \"aeiouáéíóú\"\n", - "\n", - "# Inicializa el contador\n", - "contador = 0\n", - "\n", - "# Para cada posición en el mensaje\n", - "for i in range(len(mensaje)):\n", - "\n", - " # Si el elemento actual es un signo de puntuación o una vocal\n", - " if mensaje[i] in puntuacion or mensaje[i] in vocales:\n", - "\n", - " # Imprime un mensaje\n", - " print(mensaje[i] + \" es una vocal o un signo de puntuación\")\n", - "\n", - " # Incrementa el contador\n", - " contador += 1\n", - "\n", - "# Imprime la cantidad final\n", - "print(\"El total de signos de puntuación o vocales es \" + str(contador))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## not\n", - "\n", - "- Dada la siguiente lista de enteros:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numeros = [4, 6, 7, 9]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Imprime los números que **no** son divisibles por 2:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(len(numeros)):\n", - "\n", - " # Si el número actual no es par\n", - " if not numeros[i] % 2 == 0:\n", - "\n", - " # Imprime el número actual\n", - " print(numeros[i])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Solución alternativa:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Para cada posición en la lista\n", - "for i in range(len(numeros)):\n", - "\n", - " # Si el número actual es impar\n", - " if numeros[i] % 2 != 0:\n", - "\n", - " # Imprime el número actual\n", - " print(numeros[i])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## not in\n", - "\n", - "- Genera 5 números aleatorios entre 0 y 10. Si los números aleatorios **no** están ya **en** la siguiente lista, agrégalos:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numeros = [1,4,7]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "# Repite el proceso cinco veces\n", - "for _ in range(5):\n", - "\n", - " # Genera un número aleatorio entre 0 y 10\n", - " numero = random.randint(0, 10)\n", - " # Imprime el número como comprobación\n", - " print(numero)\n", - "\n", - " # Si el nuevo número no está en la lista de números\n", - " if numero not in numeros:\n", - " # Agrégalo a la lista de números\n", - " numeros.append(numero)\n", - "\n", - "# Imprime la lista final\n", - "print(numeros)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 19. And, or, not, not in\n", + "\n", + "## Combinando y revirtiendo condiciones\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## and \n", + "\n", + "- Dada la siguiente lista de enteros:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numeros = [1, 5, 7, 2, 8, 19]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime los números que están entre 5 **y** 10:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(0, len(numeros)):\n", + "\n", + " # Si el número actual está entre 5 y 10\n", + " if numeros[i] >= 5 and numeros[i] <= 10:\n", + "\n", + " # Imprime el número actual\n", + " print(\"El número \" + str(numeros[i]) + \" está entre 5 y 10\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## or \n", + "\n", + "- Dada la siguiente cadena de texto: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mensaje = \"¡¡¡Que tengas un buen día!!!\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Y dados todos los signos de puntuación:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "puntuacion = \"\\\"/\\'()[]{}<>,.;:¿?¡!^@∼#$%&*_-\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime y cuenta el número de caracteres que son signos de puntuación **o** vocales:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cadena de vocales\n", + "vocales = \"aeiouáéíóú\"\n", + "\n", + "# Inicializa el contador\n", + "contador = 0\n", + "\n", + "# Para cada posición en el mensaje\n", + "for i in range(len(mensaje)):\n", + "\n", + " # Si el elemento actual es un signo de puntuación o una vocal\n", + " if mensaje[i] in puntuacion or mensaje[i] in vocales:\n", + "\n", + " # Imprime un mensaje\n", + " print(mensaje[i] + \" es una vocal o un signo de puntuación\")\n", + "\n", + " # Incrementa el contador\n", + " contador += 1\n", + "\n", + "# Imprime la cantidad final\n", + "print(\"El total de signos de puntuación o vocales es \" + str(contador))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## not\n", + "\n", + "- Dada la siguiente lista de enteros:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numeros = [4, 6, 7, 9]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime los números que **no** son divisibles por 2:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(len(numeros)):\n", + "\n", + " # Si el número actual no es par\n", + " if not numeros[i] % 2 == 0:\n", + "\n", + " # Imprime el número actual\n", + " print(numeros[i])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Solución alternativa:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Para cada posición en la lista\n", + "for i in range(len(numeros)):\n", + "\n", + " # Si el número actual es impar\n", + " if numeros[i] % 2 != 0:\n", + "\n", + " # Imprime el número actual\n", + " print(numeros[i])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## not in\n", + "\n", + "- Genera 5 números aleatorios entre 0 y 10. Si los números aleatorios **no** están ya **en** la siguiente lista, agrégalos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numeros = [1,4,7]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "# Repite el proceso cinco veces\n", + "for _ in range(5):\n", + "\n", + " # Genera un número aleatorio entre 0 y 10\n", + " numero = random.randint(0, 10)\n", + " # Imprime el número como comprobación\n", + " print(numero)\n", + "\n", + " # Si el nuevo número no está en la lista de números\n", + " if numero not in numeros:\n", + " # Agrégalo a la lista de números\n", + " numeros.append(numero)\n", + "\n", + "# Imprime la lista final\n", + "print(numeros)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/20_booleans.ipynb b/20_booleans.ipynb index 442fefa..5f67268 100644 --- a/20_booleans.ipynb +++ b/20_booleans.ipynb @@ -1,306 +1,306 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "# 20. ¿Qué hay detrás de las comparaciones y condiciones?\n", - "\n", - "## Booleanos\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", - "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 1. Comparación o condición simple\n", - "\n", - "- Dada la siguiente asignación:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numero = 5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Cuál es el resultado de la siguiente operación de comparación?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (numero > 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Asigna la operación anterior a una variable e imprímela. ¿Qué tipo de dato es?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "resultado = numero > 3\n", - "print(resultado)\n", - "print(type(resultado))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Cuál es el resultado de la siguiente operación de comparación?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (numero < 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Asigna la operación anterior a una variable e imprímela. ¿Qué tipo de dato es?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "resultado = numero < 3\n", - "print(resultado)\n", - "print(type(resultado))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "---\n", - "\n", - "### 2. Combinando comparaciones o condiciones\n", - "\n", - "- ¿Cuál es el resultado de las siguientes operaciones de comparación?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numero = 3\n", - "print(numero > 1) \n", - "print(numero < 5) \n", - "print(numero > 1 and numero < 5) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Qué sucede si cambiamos la primera condición para que sea falsa?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numero = 3\n", - "print(numero > 4) \n", - "print(numero < 5) \n", - "print(numero > 4 and numero < 5) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ¿Qué sucede si cambiamos la segunda condición para que sea falsa?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numero = 3\n", - "print(numero > 1) \n", - "print(numero < 2) \n", - "print(numero > 1 and numero < 2) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Finalmente, ¿qué sucede si cambiamos ambas condiciones para que sean falsas?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numero = 3\n", - "print(numero > 4) \n", - "print(numero < 2) \n", - "print(numero > 4 and numero < 2) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "\n", - "### 3. ¿Dónde más usamos booleanos?\n", - "\n", - "- Mira esta versión modificada del ejemplo *¿Quieres más dulces?* del Capítulo 17:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Inicializar variables\n", - "numero_de_dulces = 0\n", - "\n", - "# Usar el booleano como una bandera\n", - "bandera = True\n", - "\n", - "# Imprimir el número inicial de dulces\n", - "print(\"Tienes \" + str(numero_de_dulces) + \" dulces\")\n", - "\n", - "# Mientras la bandera sea True (= un semáforo verde):\n", - "while bandera == True:\n", - "\n", - " # Preguntar si se quiere un dulce\n", - " respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", - "\n", - " # Si la respuesta es sí\n", - " if respuesta == \"sí\":\n", - "\n", - " # Agregar un dulce\n", - " numero_de_dulces += 1\n", - "\n", - " # Imprimir el número total de dulces\n", - " print(\"Tienes \" + str(numero_de_dulces) + \" dulces\")\n", - "\n", - " # Si la respuesta es no\n", - " else:\n", - "\n", - " # Imprimir el número final de dulces\n", - " print(\"Tienes un total de \" + str(numero_de_dulces) + \" dulces\")\n", - "\n", - " # Detener el bucle asignando False a la bandera (= un semáforo rojo)\n", - " bandera = False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Aquí está el código del Capítulo 17 para comparación:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Inicializa tus variables\n", - "cantidad_de_dulces = 0\n", - "\n", - "# Imprime la cantidad inicial de dulces que tienes\n", - "print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", - "\n", - "# Responde si deseas un dulce\n", - "respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", - "\n", - "# Mientras tu respuesta sea sí:\n", - "while respuesta == \"sí\":\n", - "\n", - " # Agrega un dulce a tu colección\n", - " cantidad_de_dulces += 1\n", - "\n", - " # Imprime la cantidad actual de dulces que tienes\n", - " print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", - "\n", - " # Pregunta de nuevo si deseas más dulces\n", - " respuesta = input(\"¿Quieres más dulces? (sí/no)\")\n", - "\n", - "# Imprime la cantidad final de dulces que tienes\n", - "print(\"Tienes un total de \" + str(cantidad_de_dulces) + \" dulces\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.12" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "# 20. ¿Qué hay detrás de las comparaciones y condiciones?\n", + "\n", + "## Booleanos\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) (Aprende Python con Jupyter): [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Tradución al español mexicano (es-MX): [Rodrigo Ernesto Álvarez Aguilera](https://incognia.github.io/) \n", + "Licencia de contenido: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1. Comparación o condición simple\n", + "\n", + "- Dada la siguiente asignación:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 5" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Cuál es el resultado de la siguiente operación de comparación?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (numero > 3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Asigna la operación anterior a una variable e imprímela. ¿Qué tipo de dato es?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "resultado = numero > 3\n", + "print(resultado)\n", + "print(type(resultado))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Cuál es el resultado de la siguiente operación de comparación?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (numero < 3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Asigna la operación anterior a una variable e imprímela. ¿Qué tipo de dato es?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "resultado = numero < 3\n", + "print(resultado)\n", + "print(type(resultado))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "---\n", + "\n", + "### 2. Combinando comparaciones o condiciones\n", + "\n", + "- ¿Cuál es el resultado de las siguientes operaciones de comparación?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 3\n", + "print(numero > 1) \n", + "print(numero < 5) \n", + "print(numero > 1 and numero < 5) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Qué sucede si cambiamos la primera condición para que sea falsa?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 3\n", + "print(numero > 4) \n", + "print(numero < 5) \n", + "print(numero > 4 and numero < 5) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Qué sucede si cambiamos la segunda condición para que sea falsa?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 3\n", + "print(numero > 1) \n", + "print(numero < 2) \n", + "print(numero > 1 and numero < 2) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Finalmente, ¿qué sucede si cambiamos ambas condiciones para que sean falsas?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 3\n", + "print(numero > 4) \n", + "print(numero < 2) \n", + "print(numero > 4 and numero < 2) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "\n", + "### 3. ¿Dónde más usamos booleanos?\n", + "\n", + "- Mira esta versión modificada del ejemplo *¿Quieres más dulces?* del Capítulo 17:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inicializar variables\n", + "numero_de_dulces = 0\n", + "\n", + "# Usar el booleano como una bandera\n", + "bandera = True\n", + "\n", + "# Imprimir el número inicial de dulces\n", + "print(\"Tienes \" + str(numero_de_dulces) + \" dulces\")\n", + "\n", + "# Mientras la bandera sea True (= un semáforo verde):\n", + "while bandera == True:\n", + "\n", + " # Preguntar si se quiere un dulce\n", + " respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", + "\n", + " # Si la respuesta es sí\n", + " if respuesta == \"sí\":\n", + "\n", + " # Agregar un dulce\n", + " numero_de_dulces += 1\n", + "\n", + " # Imprimir el número total de dulces\n", + " print(\"Tienes \" + str(numero_de_dulces) + \" dulces\")\n", + "\n", + " # Si la respuesta es no\n", + " else:\n", + "\n", + " # Imprimir el número final de dulces\n", + " print(\"Tienes un total de \" + str(numero_de_dulces) + \" dulces\")\n", + "\n", + " # Detener el bucle asignando False a la bandera (= un semáforo rojo)\n", + " bandera = False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Aquí está el código del Capítulo 17 para comparación:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inicializa tus variables\n", + "cantidad_de_dulces = 0\n", + "\n", + "# Imprime la cantidad inicial de dulces que tienes\n", + "print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", + "\n", + "# Responde si deseas un dulce\n", + "respuesta = input(\"¿Quieres un dulce? (sí/no)\")\n", + "\n", + "# Mientras tu respuesta sea sí:\n", + "while respuesta == \"sí\":\n", + "\n", + " # Agrega un dulce a tu colección\n", + " cantidad_de_dulces += 1\n", + "\n", + " # Imprime la cantidad actual de dulces que tienes\n", + " print(\"Tienes \" + str(cantidad_de_dulces) + \" dulces\")\n", + "\n", + " # Pregunta de nuevo si deseas más dulces\n", + " respuesta = input(\"¿Quieres más dulces? (sí/no)\")\n", + "\n", + "# Imprime la cantidad final de dulces que tienes\n", + "print(\"Tienes un total de \" + str(cantidad_de_dulces) + \" dulces\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/22_for_overview.ipynb b/22_for_overview.ipynb index a0ffec7..b296ccf 100644 --- a/22_for_overview.ipynb +++ b/22_for_overview.ipynb @@ -53,14 +53,14 @@ "tags": [] }, "source": [ - "### 2.1. For loop through *indices*\n" + "### 2.1. Bucle for loop a traves de *indices*\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Capitalize each string using a for loop through *indices*:" + "- Capitalizar cada cadena usando un bucle for a través de *indices*:" ] }, { @@ -69,13 +69,13 @@ "metadata": {}, "outputs": [], "source": [ - "last_names = [\"garcia\", \"smith\", \"zhang\"]\n", + "appellidos = [\"garcia\", \"smith\", \"zhang\"]\n", "\n", - "for i in range (len(last_names)):\n", - " print (\"The element in position \" + str(i) + \" is: \" + last_names[i])\n", - " last_names[i] = last_names[i].title()\n", + "for i in range (len(appellidos)):\n", + " print (\"El elemento en posicion \" + str(i) + \" es: \" + appellidos[i])\n", + " appellidos[i] = appellidos[i].title()\n", "\n", - "print (last_names)" + "print (appellidos)" ] }, { @@ -267,7 +267,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/23_list_of_lists.ipynb b/23_list_of_lists.ipynb index df3c003..5e991a5 100644 --- a/23_list_of_lists.ipynb +++ b/23_list_of_lists.ipynb @@ -251,7 +251,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/25_dictionary_list.ipynb b/25_dictionary_list.ipynb index 4fd0849..65ddc31 100644 --- a/25_dictionary_list.ipynb +++ b/25_dictionary_list.ipynb @@ -443,7 +443,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/26_dictionary_use.ipynb b/26_dictionary_use.ipynb index 50c44e8..4cfac50 100644 --- a/26_dictionary_use.ipynb +++ b/26_dictionary_use.ipynb @@ -1,277 +1,277 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 26. Counting, compressing, and sorting\n", - "\n", - "\n", - "## What are dictionaries for?\n", - "\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/) \n", - "Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 1. Counting elements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following string:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "greetings = \"hello! how are you?\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Create a dictionary where the keys are the letters of the alphabet found in the string, and the corresponding values are the number of times each letter is present. Write the code in two ways: (1) using `if`/`else`, and (2) using `.get()` \n", - "\n", - "1. Using `if`/`else`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "letter_counter = {}\n", - "\n", - "for letter in greetings:\n", - " if letter not in letter_counter.keys():\n", - " letter_counter[letter] = 1\n", - " else:\n", - " letter_counter[letter] += 1 \n", - "\n", - "for k, v in letter_counter.items():\n", - " print (k, v)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "2. Using `.get()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "letter_counter = {}\n", - "\n", - "for letter in greetings:\n", - " letter_counter[letter] = letter_counter.get(letter, 0) + 1\n", - "\n", - "for k, v in letter_counter.items():\n", - " print (k, v) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 2. Compressing information" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following list:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sparse_vector = [0,0,0,1,0,7,0,0,4,0,0,0,8,0,0,0,6,0,0,0,0,0,0,0,9,0,0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Convert it into a dictionary:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create the dictionary\n", - "sparse_dict = {}\n", - "for i in range(len(sparse_vector)):\n", - " if sparse_vector[i] != 0:\n", - " sparse_dict[i] = sparse_vector[i]\n", - "\n", - "# save the list length \n", - "sparse_dict[\"length\"] = len(sparse_vector) \n", - " \n", - "# print\n", - "for k,v in sparse_dict.items():\n", - " print (k,v) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- How do we get back to the sparse vector? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create a list of zeros\n", - "sparse_vector_back = [0] * sparse_dict[\"length\"]\n", - "\n", - "# add nonzero values\n", - "for k,v in sparse_dict.items():\n", - " if k != \"length\":\n", - " sparse_vector_back[k] = v \n", - "\n", - "# print\n", - "print (sparse_vector_back)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 3. Sorting dictionary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following dictionary:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "registry = {\"Shaili\":4, \"Chris\":90, \"Maria\":70}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Sort the dictionary items according to their *keys*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create a new dictionary\n", - "sorted_registry= {}\n", - "\n", - "# sort the keys\n", - "sorted_keys = list(registry.keys())\n", - "sorted_keys.sort()\n", - "\n", - "# fill out the new dictionary\n", - "for k in sorted_keys:\n", - " sorted_registry[k] = registry[k]\n", - " \n", - "print (sorted_registry)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Sort the dictionary items according to their *values*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create a new dictionary\n", - "sorted_registry = {}\n", - "\n", - "# sort keys according to values \n", - "sorted_keys = sorted(registry, key=registry.get) \n", - "\n", - "# fill out the new dictionary\n", - "for k in sorted_keys:\n", - " sorted_registry[k] = registry[k]\n", - " \n", - "print (sorted_registry)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.7" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 26. Contando, comprimiendo y ordenando\n", + "\n", + "\n", + "## ¿Para qué sirven los diccionarios?\n", + "\n", + "\n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia narrativa: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/) \n", + "Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 1. Contando elementos" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "saludos = \"¡hola! ¿cómo estás?\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Crea un diccionario donde las claves sean las letras del alfabeto encontradas en la cadena, y los valores correspondientes sean el número de veces que cada letra está presente. Escribe el código de dos maneras: (1) usando `if`/`else`, y (2) usando `.get()` \n", + "\n", + "1. Usando `if`/`else`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "contador_letras = {}\n", + "\n", + "for letra in saludos:\n", + " if letra not in contador_letras.keys():\n", + " contador_letras[letra] = 1\n", + " else:\n", + " contador_letras[letra] += 1 \n", + "\n", + "for k, v in contador_letras.items():\n", + " print (k, v)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "2. Usando `.get()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "contador_letras = {}\n", + "\n", + "for letra in saludos:\n", + " contador_letras[letra] = contador_letras.get(letra, 0) + 1\n", + "\n", + "for k, v in contador_letras.items():\n", + " print (k, v) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Comprimiendo información" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente lista:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vector_dispar = [0,0,0,1,0,7,0,0,4,0,0,0,8,0,0,0,6,0,0,0,0,0,0,0,9,0,0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Conviértela en un diccionario:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crea el diccionario\n", + "diccionario_dispar = {}\n", + "for i in range(len(vector_dispar)):\n", + " if vector_dispar[i] != 0:\n", + " diccionario_dispar[i] = vector_dispar[i]\n", + "\n", + "# guarda la longitud de la lista \n", + "diccionario_dispar[\"longitud\"] = len(vector_dispar) \n", + " \n", + "# imprime\n", + "for k,v in diccionario_dispar.items():\n", + " print (k,v) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- ¿Cómo volvemos al vector disperso? " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crea una lista de ceros\n", + "vector_dispar_de_vuelta = [0] * diccionario_dispar[\"longitud\"]\n", + "\n", + "# añade valores no nulos\n", + "for k,v in diccionario_dispar.items():\n", + " if k != \"longitud\":\n", + " vector_dispar_de_vuelta[k] = v \n", + "\n", + "# imprime\n", + "print (vector_dispar_de_vuelta)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Ordenando diccionario" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dado el siguiente diccionario:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "registro = {\"Shaili\":4, \"Chris\":90, \"Maria\":70}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Ordena los elementos del diccionario según sus *claves*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crea un nuevo diccionario\n", + "registro_ordenado= {}\n", + "\n", + "# ordena las claves\n", + "claves_ordenadas = list(registro.keys())\n", + "claves_ordenadas.sort()\n", + "\n", + "# llena el nuevo diccionario\n", + "for k in claves_ordenadas:\n", + " registro_ordenado[k] = registro[k]\n", + " \n", + "print (registro_ordenado)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Ordena los elementos del diccionario según sus *valores*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crea un nuevo diccionario\n", + "registro_ordenado = {}\n", + "\n", + "# ordena las claves según los valores \n", + "claves_ordenadas = sorted(registro, key=registro.get) \n", + "\n", + "# llena el nuevo diccionario\n", + "for k in claves_ordenadas:\n", + " registro_ordenado[k] = registro[k]\n", + " \n", + "print (registro_ordenado)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.7" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/27_strings_overview.ipynb b/27_strings_overview.ipynb index 69fb9bb..fd82eca 100644 --- a/27_strings_overview.ipynb +++ b/27_strings_overview.ipynb @@ -1,613 +1,613 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 27. Overview of strings \n", - "\n", - "## Operations, methods, and printing\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 1. String slicing\n", - "\n", - "String slicing is the same as list slicing.\n", - "\n", - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "two_ways = \"rsecwyadrkd\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Extract every second character:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (two_ways[::2])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Extract every second character and invert the outcome:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print (two_ways[::-2])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 2. \"Arithmetic\" operations among strings\n", - "\n", - "In python, only two \"arithmetic\" operations are possible on strings (same as for lists): \n", - "- Concatenations (`+`)\n", - "- Self-replication (`*`)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Concatenate two strings:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "first = \"sun\"\n", - "second = \"screen\"\n", - "combo = first + second \n", - "print (combo)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Replicate a string 5 times:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "one_smile = \":-)\"\n", - "five_smiles = one_smile * 5\n", - "print (five_smiles)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- \n", - "## 3. Replacing or removing parts of strings\n", - "\n", - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "favorites = \"I like cooking, my family, and my friends\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Replace** the character at position 0 with `U` using slicing and assignment. What happens?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "favorites[0] = \"U\" " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Redo the same task using slicing and concatenation: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from_position_one = favorites[1:]\n", - "favorites = \"U\" + from_position_one\n", - "print (favorites)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Redo the same task using the string method `.split()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "favorites = \"I like cooking, my family, and my friends\"\n", - "\n", - "parts = favorites.split(\"I\")\n", - "print (parts)\n", - "\n", - "favorites = \"U\" + parts[1]\n", - "print (favorites)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Replace** the commas with semicolons using the method `.replace()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "favorites = \"I like cooking, my family, and my friends\"\n", - "favorites = favorites.replace(\",\", \";\") #reassingment\n", - "print (favorites)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Remove** the commas:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "favorites = \"I like cooking, my family, and my friends\"\n", - "favorites = favorites.replace(\",\", \"\") # two things at once: replace and removing (or using replace to removing)\n", - "print (favorites)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 4. Searching a substring in a string\n", - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "us = \"we are\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Find the positions of the character `e` using the method `.find()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "positions = us.find(\"e\")\n", - "print (positions)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Find all the positions of the character *e* using an alternative way:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# initializing positions \n", - "positions = []\n", - "\n", - "# find all positions of e\n", - "for i in range(len(us)):\n", - " if us[i] == \"e\":\n", - " positions.append(i)\n", - "print (positions)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Find the position of the character `f` using the method `.find()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "positions = us.find(\"f\")\n", - "print (positions)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 5. Counting the number of substrings in a string" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "hobbies = \"I like going to the movies, traveling, and singing\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Count the numbers of substrings `ing` using the method `.count()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "n_substrings = hobbies.count(\"ing\")\n", - "print (n_substrings)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 6. String to list and back \n", - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "string = \"How are you\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Transform the string into a list of strings where each element is a word: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "list_of_strings = string.split() \n", - "print (list_of_strings)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Transform the list of strings back to a string using the method `.join()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "string_from_list = \" \".join(list_of_strings)\n", - "print (string_from_list)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 7. Changing character cases \n", - "- Given the following string: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "greeting = \"Hello! How are you?\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Modify the string to uppercase and lowercase; change to uppercase only the first character of the string, and then each word of the string; finally, invert the cases:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# uppercase\n", - "print (greeting.upper())\n", - "# lowercase\n", - "print (greeting.lower())\n", - "# change the first character of the to uppercase\n", - "print (greeting.capitalize())\n", - "# change the first character of each word to uppercase\n", - "print (greeting.title())\n", - "# invert cases\n", - "print (greeting.swapcase())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 8. Printing variables" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following string:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "part_of_day = \"morning\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print `Good morning!` in 4 ways, using (1) string concatenation, (2) comma separation, (3) the method `.format()`, and (4) *f-strings*, and notice the differences:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# (1) string concatenation\n", - "print (\"Good \" + part_of_day + \"!\")\n", - "# (2) variable separation by comma\n", - "print (\"Good\", part_of_day, \"!\")\n", - "# (3) the method .format()\n", - "print (\"Good {}!\".format(part_of_day))\n", - "# (4) f-strings\n", - "print (f\"\"\"Good {part_of_day}!\"\"\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given a string and a numerical variable:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "part_of_day = \"morning\"\n", - "time_of_day = 10" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print \n", - " `Good morning!` \n", - " `It's 10a.m.` \n", - " using the same four ways as above (note that the sentences are on two separate lines):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# (1) string concatenation\n", - "print (\"Good \" + part_of_day + \"!\\nIt's \" + str(time_of_day) + \"a.m.\")\n", - "# (2) variable separation by comma\n", - "print (\"Good\", part_of_day, \"!\\nIt's\", time_of_day, \"a.m\")\n", - "# (3) the method .format()\n", - "print (\"Good {}!\\nIt's {}a.m.\".format(part_of_day, time_of_day))\n", - "# (4) f-strings\n", - "print (f\"\"\"Good {part_of_day}! \n", - "It's {time_of_day}a.m.\"\"\")\n", - "# notes:\n", - "# - apostrophe with single quote requires \\' (see first line It's)\n", - "# - use of \\n\n", - "# - with f-strings one can go to a new line if using triple quotes" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the numerical variable:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "number = 1.2345" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print `The number is 1.23` (only the first two decimals) using the four methods:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# (1) string concatenation\n", - "print(\"The number is \" + str(round(number, 2)))\n", - "# (2) variable separation by comma\n", - "print(\"The number is\", round(number, 2))\n", - "# (3) the method .format()\n", - "print(\"The number is {:.2f}\".format(number))\n", - "# (4) f-strings\n", - "print(f\"\"\"The number is {number:.2f}\"\"\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.6" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 27. Descripción general de las cadenas (strings)\n", + "\n", + "## Operaciones, métodos e impresión\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 1. Rebanado de cadenas (String slicing)\n", + "\n", + "El rebanado de cadenas es lo mismo que el rebanado de listas.\n", + "\n", + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dos_caminos = \"rsecwyadrkd\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Extrae cada segundo carácter:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (dos_caminos[::2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Extrae cada segundo carácter e invierte el resultado:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print (dos_caminos[::-2])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. Operaciones \"aritméticas\" entre cadenas\n", + "\n", + "En Python, solo dos operaciones \"aritméticas\" son posibles en cadenas (igual que para las listas):\n", + "- Concatenaciones (`+`)\n", + "- Auto-replicación (`*`)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Concatena dos cadenas:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "primero = \"sol\"\n", + "segundo = \"pantalla\"\n", + "combinacion = primero + segundo\n", + "print (combinacion)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Replica una cadena 5 veces:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "una_sonrisa = \":-)\"\n", + "cinco_sonrisas = una_sonrisa * 5\n", + "print (cinco_sonrisas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 3. Reemplazar o eliminar partes de cadenas\n", + "\n", + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favoritos = \"Me gusta cocinar, mi familia y mis amigos\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Reemplaza** el carácter en la posición 0 con `U` usando rebanado y asignación. ¿Qué pasa?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "favoritos[0] = \"U\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Rehace la misma tarea usando rebanado y concatenación:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "desde_posicion_uno = favoritos[1:]\n", + "favoritos = \"U\" + desde_posicion_uno\n", + "print (favoritos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Rehace la misma tarea usando el método de cadena `.split()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favoritos = \"Me gusta cocinar, mi familia y mis amigos\"\n", + "\n", + "partes = favoritos.split(\"Me\")\n", + "print (partes)\n", + "\n", + "favoritos = \"U\" + partes[1]\n", + "print (favoritos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Reemplaza** las comas con punto y comas usando el método `.replace()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favoritos = \"Me gusta cocinar, mi familia y mis amigos\"\n", + "favoritos = favoritos.replace(\",\", \";\") #reasignación\n", + "print (favoritos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- **Elimina** las comas:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "favoritos = \"Me gusta cocinar, mi familia y mis amigos\"\n", + "favoritos = favoritos.replace(\",\", \"\") # dos cosas a la vez: reemplazar y eliminar (o usar reemplazar para eliminar)\n", + "print (favoritos)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. Buscar una subcadena en una cadena\n", + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nosotros = \"nosotros somos\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Encuentra las posiciones del carácter `e` usando el método `.find()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "posiciones = nosotros.find(\"e\")\n", + "print (posiciones)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Encuentra todas las posiciones del carácter *e* usando una forma alternativa:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# inicializando posiciones\n", + "posiciones = []\n", + "\n", + "# encuentra todas las posiciones de e\n", + "for i in range(len(nosotros)):\n", + " if nosotros[i] == \"e\":\n", + " posiciones.append(i)\n", + "print (posiciones)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Encuentra la posición del carácter `f` usando el método `.find()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "posiciones = nosotros.find(\"f\")\n", + "print (posiciones)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 5. Contar el número de subcadenas en una cadena" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pasatiempos = \"Me gusta ir al cine, viajar y cantar\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Cuenta el número de subcadenas `ando` usando el método `.count()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "n_subcadenas = pasatiempos.count(\"ar\")\n", + "print (n_subcadenas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 6. Cadena a lista y viceversa\n", + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cadena = \"Cómo estás\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Transforma la cadena en una lista de cadenas donde cada elemento es una palabra:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lista_de_cadenas = cadena.split()\n", + "print (lista_de_cadenas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Transforma la lista de cadenas de nuevo a una cadena usando el método `.join()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cadena_desde_lista = \" \".join(lista_de_cadenas)\n", + "print (cadena_desde_lista)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 7. Cambiar mayúsculas y minúsculas\n", + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "saludo = \"¡Hola! ¿Cómo estás?\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Modifica la cadena a mayúsculas y minúsculas; cambia a mayúscula solo el primer carácter de la cadena, y luego cada palabra de la cadena; finalmente, invierte los casos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# mayúsculas\n", + "print (saludo.upper())\n", + "# minúsculas\n", + "print (saludo.lower())\n", + "# cambia el primer carácter a mayúscula\n", + "print (saludo.capitalize())\n", + "# cambia el primer carácter de cada palabra a mayúscula\n", + "print (saludo.title())\n", + "# invierte casos\n", + "print (saludo.swapcase())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 8. Imprimir variables" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente cadena:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parte_del_dia = \"mañana\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime `¡Buenos días!` de 4 maneras, usando (1) concatenación de cadenas, (2) separación por comas, (3) el método `.format()` y (4) *f-strings*, y observa las diferencias:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) concatenación de cadenas\n", + "print (\"¡Buenos \" + parte_del_dia + \"!\")\n", + "# (2) separación de variables por coma\n", + "print (\"Buenos\", parte_del_dia, \"!\")\n", + "# (3) el método .format()\n", + "print (\"¡Buenos {}!\".format(parte_del_dia))\n", + "# (4) f-strings\n", + "print (f\"\"\"¡Buenos {parte_del_dia}!\"\"\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dadas una cadena y una variable numérica:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parte_del_dia = \"mañana\"\n", + "hora_del_dia = 10" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime\n", + " `¡Buenos días!`\n", + " `Son las 10 a.m.`\n", + "usando las mismas cuatro formas que antes (ten en cuenta que las frases están en dos líneas separadas):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) concatenación de cadenas\n", + "print (\"¡Buenos \" + parte_del_dia + \"!\\nSon las \" + str(hora_del_dia) + \"a.m.\")\n", + "# (2) separación de variables por coma\n", + "print (\"Buenos\", parte_del_dia, \"!\\nSon las\", hora_del_dia, \"a.m\")\n", + "# (3) el método .format()\n", + "print (\"¡Buenos {}!\\nSon las {}a.m.\".format(parte_del_dia, hora_del_dia))\n", + "# (4) f-strings\n", + "print (f\"\"\"¡Buenos {parte_del_dia}! \\n\n", + "Son las {hora_del_dia}a.m.\"\"\")\n", + "# notas:\n", + "# - apóstrofe con comilla simple requiere \\' (ver primera línea Son las)\n", + "# - uso de \\n\n", + "# - con f-strings uno puede ir a una nueva línea si usa triples comillas" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la variable numérica:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numero = 1.2345" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime `El número es 1.23` (solo los dos primeros decimales) usando los cuatro métodos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# (1) concatenación de cadenas\n", + "print(\"El número es \" + str(round(numero, 2)))\n", + "# (2) separación de variables por coma\n", + "print(\"El número es\", round(numero, 2))\n", + "# (3) el método .format()\n", + "print(\"El número es {:.2f}\".format(numero))\n", + "# (4) f-strings\n", + "print(f\"\"\"El número es {numero:.2f}\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/28_function_inputs.ipynb b/28_function_inputs.ipynb index 3317975..4b3372d 100644 --- a/28_function_inputs.ipynb +++ b/28_function_inputs.ipynb @@ -1,285 +1,285 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 28. Printing *Thank you* cards\n", - "\n", - "## Function inputs\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Basic *Thank you* cards\n", - "- You recently hosted a party, and you want to send *Thank you* cards to those who attended. Create\n", - "a function that takes a first name as an argument and prints a *Thank you* message containing an\n", - "attendee’s name (e.g., *Thank you Maria*): " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def print_thank_you(first_name): \n", - " \"\"\"Prints a string containing \"Thank you\" and a first name\n", - " \n", - " Parameters\n", - " ----------\n", - " first_name: string\n", - " First name of a person\n", - " \"\"\"\n", - " \n", - " print (\"Thank you\", first_name)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print two *Thank you* cards: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Maria\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Xiao\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 2. Formal *Thank you* cards\n", - "- After a second thought, you decide that it is more appropriate to print formal Thank you cards. Mod-\n", - "ify the previous function to take three arguments—prefix, first name, and last name—and to print\n", - "a thank you message containing them (e.g., *Thank you Mrs. Maria Lopez*): " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def print_thank_you(prefix, first_name, last_name): \n", - " \"\"\"Prints a string containing \"Thank you\" and the inputs\n", - " \n", - " Parameters\n", - " ----------\n", - " prefix: string\n", - " Usually Ms, Mrs, Mr\n", - " first_name: string\n", - " First name of a person\n", - " last_name: string\n", - " Last name of a person\n", - " \"\"\"\n", - "\n", - " print (\"Thank you\", prefix, first_name, last_name)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print two formal *Thank you* cards: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Mrs\", \"Maria\", \"Lopez\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Mr\", \"Xiao\", \"Li\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 3. Last name missing! \n", - "- You are very happy with the *Thank you* cards, but you suddenly realize that some participants did\n", - "not provide their last names! Adapt the function so that the last name has an empty string as a\n", - "default value:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def print_thank_you(prefix, first_name, last_name=\"\"): \n", - " \"\"\"Prints a string containing \"Thank you\" and the inputs\n", - " \n", - " Parameters\n", - " ----------\n", - " prefix: string\n", - " Usually Ms, Mrs, Mr\n", - " first_name: string\n", - " First name of a person\n", - " last_name: string\n", - " Last name of a person. The default is an empty string\n", - " \"\"\"\n", - " \n", - " print (\"Thank you\", prefix, first_name, last_name)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print two *Thank you* cards, one with a last name and one without a last name:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Mrs\", \"Maria\", \"Lopez\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print_thank_you(\"Mr\", \"Xiao\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 4. Prefix and/or first name missing! \n", - "- Finally, you realize that prefix and/or first name are also missing for some guests. Modify the function accordingly:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def print_thank_you(prefix=\"\", first_name=\"\", last_name=\"\"): \n", - " \"\"\"Prints each input and a string containing \"Thank you\" and the inputs\n", - " \n", - " Parameters\n", - " ----------\n", - " prefix: string\n", - " Usually Ms, Mrs, Mr. The default is an empty string\n", - " first_name: string\n", - " First name of a person. The default is an empty string\n", - " last_name: string\n", - " Last name of a person. The default is an empty string\n", - " \"\"\"\n", - " \n", - " print (\"Prefix:\", prefix)\n", - " print (\"First name:\", first_name)\n", - " print (\"Last name:\", last_name)\n", - " print (\"Thank you\", prefix, first_name, last_name)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print a *Thank you* card where the *first name* is missing:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "print_thank_you(prefix=\"Mrs\", last_name=\"Lopez\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Print a *Thank you* card where the *prefix* is missing:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "print_thank_you(first_name=\"Xiao\", last_name=\"Li\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.6" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 28. Imprimiendo tarjetas de *Agradecimiento*\n", + "\n", + "## Entradas de la función\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Tarjetas básicas de *Agradecimiento*\n", + "- Recientemente organizaste una fiesta y quieres enviar tarjetas de *Agradecimiento* a los que asistieron. Crea\n", + "una función que tome un nombre como argumento e imprima un mensaje de *Agradecimiento* que contenga el\n", + "nombre del asistente (p. ej., *Gracias Maria*): " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def imprimir_agradecimiento(nombre):\n", + " \"\"\"Imprime una cadena que contiene \"Gracias\" y un nombre\n", + " \n", + " Parámetros\n", + " ----------\n", + " nombre: string\n", + " Nombre de una persona\n", + " \"\"\"\n", + " \n", + " print (\"Gracias\", nombre)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime dos tarjetas de *Agradecimiento*: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Maria\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Xiao\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Tarjetas formales de *Agradecimiento*\n", + "- Después de pensarlo mejor, decides que es más apropiado imprimir tarjetas formales de Agradecimiento. Modifica\n", + "la función anterior para que tome tres argumentos: prefijo, nombre y apellido, e imprima\n", + "un mensaje de agradecimiento que los contenga (p. ej., *Gracias Sra. Maria Lopez*): " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def imprimir_agradecimiento(prefijo, nombre, apellido):\n", + " \"\"\"Imprime una cadena que contiene \"Gracias\" y las entradas\n", + " \n", + " Parámetros\n", + " ----------\n", + " prefijo: string\n", + " Normalmente Sr, Sra, Srta\n", + " nombre: string\n", + " Nombre de una persona\n", + " apellido: string\n", + " Apellido de una persona\n", + " \"\"\"\n", + "\n", + " print (\"Gracias\", prefijo, nombre, apellido)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime dos tarjetas formales de *Agradecimiento*: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Sra\", \"Maria\", \"Lopez\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Sr\", \"Xiao\", \"Li\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. ¡Apellido faltante! \n", + "- Estás muy contento con las tarjetas de *Agradecimiento*, ¡pero de repente te das cuenta de que algunos participantes no\n", + "proporcionaron sus apellidos! Adapta la función para que el apellido tenga una cadena vacía como\n", + "valor predeterminado:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def imprimir_agradecimiento(prefijo, nombre, apellido=\"\"):\n", + " \"\"\"Imprime una cadena que contiene \"Gracias\" y las entradas\n", + " \n", + " Parámetros\n", + " ----------\n", + " prefijo: string\n", + " Normalmente Sr, Sra, Srta\n", + " nombre: string\n", + " Nombre de una persona\n", + " apellido: string\n", + " Apellido de una persona. El valor predeterminado es una cadena vacía\n", + " \"\"\"\n", + " \n", + " print (\"Gracias\", prefijo, nombre, apellido)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime dos tarjetas de *Agradecimiento*, una con apellido y otra sin apellido:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Sra\", \"Maria\", \"Lopez\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "imprimir_agradecimiento(\"Sr\", \"Xiao\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. ¡Prefijo y/o nombre faltantes! \n", + "- Finalmente, te das cuenta de que el prefijo y/o el nombre también faltan para algunos invitados. Modifica la función en consecuencia:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def imprimir_agradecimiento(prefijo=\"\", nombre=\"\", apellido=\"\"):\n", + " \"\"\"Imprime cada entrada y una cadena que contiene \"Gracias\" y las entradas\n", + " \n", + " Parámetros\n", + " ----------\n", + " prefijo: string\n", + " Normalmente Sr, Sra, Srta. El valor predeterminado es una cadena vacía\n", + " nombre: string\n", + " Nombre de una persona. El valor predeterminado es una cadena vacía\n", + " apellido: string\n", + " Apellido de una persona. El valor predeterminado es una cadena vacía\n", + " \"\"\"\n", + " \n", + " print (\"Prefijo:\", prefijo)\n", + " print (\"Nombre:\", nombre)\n", + " print (\"Apellido:\", apellido)\n", + " print (\"Gracias\", prefijo, nombre, apellido)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime una tarjeta de *Agradecimiento* donde falta el *nombre*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "imprimir_agradecimiento(prefijo=\"Sra\", apellido=\"Lopez\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Imprime una tarjeta de *Agradecimiento* donde falta el *prefijo*:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "imprimir_agradecimiento(nombre=\"Xiao\", apellido=\"Li\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/29_function_outputs.ipynb b/29_function_outputs.ipynb index bb261f9..6e8a92d 100644 --- a/29_function_outputs.ipynb +++ b/29_function_outputs.ipynb @@ -1,297 +1,297 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 29. Login database for an online store\n", - "\n", - "## Function outputs and modular design\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- You are the owner of an online store and need to securely store usernames and passwords of your customers. Create a database where usernames are composed of the initial of the customer’s first name followed by their last name (e.g., “jsmith”), and passwords consist of a four-digit code" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 1. Creating a username" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Write a function that creates a username composed of the initial of the first name and the last name:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def create_username (first_name, last_name):\n", - " \"\"\"Create a lowercase username made of initial of first name and full last name\n", - " \n", - " Parameters\n", - " ----------\n", - " first_name: string \n", - " First name of a person\n", - " last_name: string\n", - " Last name of a person\n", - " \n", - " Returns \n", - " -------\n", - " username: string\n", - " Created username \n", - " \"\"\"\n", - " \n", - " # concatenate initial of first name and last name\n", - " username = first_name[0] + last_name\n", - " # make sure username is lowercase\n", - " username = username.lower()\n", - " \n", - " # return username\n", - " return username" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Test the function for two customers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "username_1 = create_username (\"Julia\", \"Smith\") \n", - "print (username_1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "username_2 = create_username (\"Mohammed\", \"Seid\")\n", - "print (username_2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 2. Creating a password\n", - "- Write a function that creates a password composed of four random integers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "def create_password():\n", - " \"\"\"Create a password composed of four random integers \n", - " \n", - " Returns \n", - " -------\n", - " password: string\n", - " Created password \n", - " \"\"\"\n", - " \n", - " # create a random number with four digits\n", - " password = str(random.randint(1000,9999))\n", - " \n", - " # return password\n", - " return password" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Test the function for two customers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "password_1 = create_password()\n", - "print (password_1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "password_2 = create_password()\n", - "print (password_2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## 3. Creating a database\n", - "\n", - "- Write a function that, given a list of lists of customers, creates and returns a database (i.e., a dictionary) of usernames and passwords. The function also returns the number of customers in the\n", - "database:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def create_database (customers): \n", - " \"\"\"Creates a database as a dictionary with usernames as keys and passwords as values \n", - " \n", - " Parameters\n", - " ----------\n", - " customers : list of lists\n", - " Each sublist contains first name and last name of a customer\n", - " \n", - " Returns \n", - " -------\n", - " db : dictionary\n", - " Created database (shorted as db)\n", - " n_customers : int\n", - " Number of customers in the database\n", - " \"\"\"\n", - " \n", - " # initialize dictionary (i.e. database)\n", - " db = {}\n", - " \n", - " # for each customer\n", - " for customer in customers:\n", - "\n", - " # create username\n", - " username = create_username (customer[0], customer[1])\n", - "\n", - " # create password\n", - " password = create_password() \n", - " \n", - " # add username and password to db\n", - " db[username] = password\n", - " \n", - " # compute number of customers \n", - " n_customers = len(db)\n", - "\n", - " # return dictionary and its length\n", - " return db, n_customers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Given the following list of customers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "customers = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Create the database using two different syntaxes:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create the database - separate returns\n", - "database, number_customers = create_database(customers)\n", - "\n", - "# print the outputs\n", - "print (\"Database:\", database)\n", - "print (\"Number of customers:\", number_customers) " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# create the database - single return\n", - "outputs = create_database(customers)\n", - "print (\"Output tuple:\", outputs)\n", - "\n", - "# get and print the database\n", - "database = outputs[0]\n", - "print(\"Database:\", database)\n", - " \n", - "# get and print the number of customers\n", - "number_customers = outputs[1]\n", - "print (\"Number of customers:\", number_customers) " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.6" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 29. Base de datos de inicio de sesión para una tienda online\n", + "\n", + "## Salidas de funciones y diseño modular\n", + "\n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia de narrativa: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Eres el propietario de una tienda online y necesitas almacenar de forma segura los nombres de usuario y contraseñas de tus clientes. Crea una base de datos donde los nombres de usuario estén compuestos por la inicial del nombre del cliente seguida de su apellido (por ejemplo, \"jsmith\"), y las contraseñas consistan en un código de cuatro dígitos" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 1. Creando un nombre de usuario" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Escribe una función que cree un nombre de usuario compuesto por la inicial del nombre y el apellido completo:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def crear_usuario (nombre, appelido):\n", + " \"\"\"Crea un nombre de usuario en minúsculas formado por la inicial del nombre y el apellido completo\n", + "\n", + " Parámetros\n", + " ----------\n", + " nombre: string\n", + " Nombre de una persona\n", + " apellido: string\n", + " Apellido de una persona\n", + "\n", + " Retorna\n", + " -------\n", + " username: string\n", + " Nombre de usuario creado\n", + " \"\"\"\n", + "\n", + " # concatenar la inicial del nombre y el apellido\n", + " usuario = nombre[0] + appelido\n", + " # asegurar que el nombre de usuario esté en minúsculas\n", + " usuario = usuario.lower()\n", + "\n", + " # retornar nombre de usuario\n", + " return usuario" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Prueba la función para dos clientes:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "usuario_1 = crear_usuario (\"Julia\", \"Smith\")\n", + "print (usuario_1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "usuario_2 = crear_usuario (\"Mohammed\", \"Seid\")\n", + "print (usuario_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Creando una contraseña\n", + "- Escribe una función que cree una contraseña compuesta por cuatro enteros aleatorios:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "def crear_contrasena():\n", + " \"\"\"Crea una contraseña compuesta por cuatro enteros aleatorios\n", + "\n", + " Retorna\n", + " -------\n", + " password: string\n", + " Contraseña creada\n", + " \"\"\"\n", + "\n", + " # crear un número aleatorio con cuatro dígitos\n", + " contrasena = str(random.randint(1000,9999))\n", + "\n", + " # retornar contraseña\n", + " return contrasena" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Prueba la función para dos clientes:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "contrasena_1 = crear_contrasena()\n", + "print (contrasena_1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "contrasena_2 = crear_contrasena()\n", + "print (contrasena_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Creando una base de datos\n", + "\n", + "- Escribe una función que, dada una lista de listas de clientes, cree y devuelva una base de datos (es decir, un diccionario) de nombres de usuario y contraseñas. La función también devuelve el número de clientes en la\n", + "base de datos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def crear_base_datos (clientes):\n", + " \"\"\"Crea una base de datos como un diccionario con nombres de usuario como claves y contraseñas como valores\n", + "\n", + " Parámetros\n", + " ----------\n", + " customers : lista de listas\n", + " Cada sublista contiene nombre y apellido de un cliente\n", + "\n", + " Retorna\n", + " -------\n", + " db : diccionario\n", + " Base de datos creada (abreviado como db)\n", + " n_customers : entero\n", + " Número de clientes en la base de datos\n", + " \"\"\"\n", + "\n", + " # inicializar diccionario (es decir, base de datos)\n", + " db = {}\n", + "\n", + " # para cada cliente\n", + " for cliente in clientes:\n", + "\n", + " # crear nombre de usuario\n", + " usuario = crear_usuario (cliente[0], cliente[1])\n", + "\n", + " # crear contraseña\n", + " contrasena = crear_contrasena()\n", + "\n", + " # agregar nombre de usuario y contraseña a db\n", + " db[usuario] = contrasena\n", + "\n", + " # calcular número de clientes\n", + " n_clientes = len(db)\n", + "\n", + " # retornar diccionario y su longitud\n", + " return db, n_clientes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Dada la siguiente lista de clientes:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "clientes = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Crea la base de datos utilizando dos sintaxis diferentes:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crear la base de datos - retornos separados\n", + "database, n_clientes = crear_base_datos(clientes)\n", + "\n", + "# imprimir las salidas\n", + "print (\"Base de datos:\", database)\n", + "print (\"Número de clientes:\", n_clientes)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# crear la base de datos - retorno único\n", + "outputs = crear_base_datos(clientes)\n", + "print (\"Tupla de salida:\", outputs)\n", + "\n", + "# obtener e imprimir la base de datos\n", + "database = outputs[0]\n", + "print(\"Base de datos:\", database)\n", + "\n", + "# obtener e imprimir el número de clientes\n", + "n_clientes = outputs[1]\n", + "print (\"Número de clientes:\", n_clientes)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/30_function_io_extra.ipynb b/30_function_io_extra.ipynb index 51d8162..dcedc79 100644 --- a/30_function_io_extra.ipynb +++ b/30_function_io_extra.ipynb @@ -1,228 +1,228 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 30. Free ticket at the museum\n", - "\n", - "## Input validation and outputs variations\n", - "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- You work at a museum and have to update the online system to buy tickets. The update is that people who are 65 and older now qualify for a free ticket. Write a function that asks visitors to enter their prefix, last name, and age; checks the *types* and *values* of these inputs; and returns a message telling the visitor if they are eligible for a free ticket." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def free_museum_ticket(prefix, last_name, age): \n", - " \"\"\"Returns a message containing inputs and free ticket eligibility based on age\n", - " E.g. Mrs. Holmes, you are eligible for a free museum ticket because you are 66\n", - " \n", - " Parameters\n", - " ----------\n", - " prefix : string\n", - " Ms, Mrs, Mr\n", - " last_name : string\n", - " Last name of a visitor\n", - " age : integer\n", - " Age of a visitor\n", - " \n", - " Returns\n", - " -------\n", - " string \n", - " Message containing visitor inputs and eligibility\n", - " \"\"\"\n", - " \n", - " # --- checking parameter types ---\n", - " \n", - " # the type of prefix must be string\n", - " if not isinstance (prefix, str): \n", - " raise TypeError (\"prefix must be a string\")\n", - " \n", - " # the type of last_name must be string\n", - " if not isinstance (last_name, str): \n", - " raise TypeError (\"last_name must be a string\")\n", - " \n", - " # the type of age must be integer\n", - " if not isinstance (age, int): \n", - " raise TypeError (\"age must be an integer\") \n", - "\n", - " \n", - " # --- checking parameter values ---\n", - " \n", - " # prefix must be Ms, Mrs, or Mr\n", - " if prefix not in [\"Ms\", \"Mrs\", \"Mr\"]:\n", - " raise ValueError (\"prefix must be Ms, Mrs, or Mr\")\n", - " \n", - " # last_name must contain only characters \n", - " if not last_name.isalpha():\n", - " raise ValueError (\"last_name must contain only letters\")\n", - " \n", - " # age has to be between 0 and 125\n", - " if age < 0 or age > 125:\n", - " raise ValueError (\"age must be between 0 and 125\")\n", - "\n", - " \n", - " # --- returning output ---\n", - "\n", - " if age >= 65:\n", - " return prefix + \". \" + last_name + \", you are eligible for a free museum ticket because you are \" + str(age)\n", - " else:\n", - " return prefix + \". \" + last_name + \", you are not eligible for a free museum ticket because you are \" + str(age) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "- Call the function checking the parameter *types*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking prefix type\n", - "message = free_museum_ticket(1, \"Holmes\", 66)\n", - "print (message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking last_name type\n", - "message = free_museum_ticket(\"Mrs\", 1.2, 66)\n", - "print (message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking age type\n", - "message = free_museum_ticket(\"Mrs\", \"Holmes\", \"Hi\") \n", - "print (message)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "- Call the function checking parameter *values*:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking prefix value\n", - "message = free_museum_ticket(\"Dr\", \"Holmes\", 66)\n", - "print (message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking last_name value\n", - "message = free_museum_ticket(\"Mrs\", \"82\", 66)\n", - "print (message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# checking age value\n", - "message = free_museum_ticket(\"Mrs\", \"Holmes\", 130)\n", - "print (message)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "- Call the function testing the two possible returns:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# person is eligible\n", - "message = free_museum_ticket(\"Mrs\", \"Holmes\", 66)\n", - "print (message)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# person is not eligible\n", - "message = free_museum_ticket(\"Mrs\", \"Choi\", 38)\n", - "print (message)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.6" - }, - "widgets": { - "application/vnd.jupyter.widget-state+json": { - "state": {}, - "version_major": 2, - "version_minor": 0 - } - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 30. Entrada gratuita al museo\n", + "\n", + "## Validación de entrada y variaciones de salida\n", + "\n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia de narrativa: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Trabajas en un museo y tienes que actualizar el sistema en línea para comprar entradas. La actualización es que las personas de 65 años o más ahora califican para una entrada gratuita. Escribe una función que pida a los visitantes que ingresen su prefijo, apellido y edad; verifique los *tipos* y *valores* de estas entradas; y devuelva un mensaje que le diga al visitante si es elegible para una entrada gratuita." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def entrada_gratuita_mueso(prefijo, appelido, edad):\n", + " \"\"\"Retorna un mensaje que contiene las entradas y la elegibilidad para una entrada gratuita al museo basada en la edad\n", + " Por ejemplo: Sra. Holmes, usted es elegible para una entrada gratuita al museo porque tiene 66 años\n", + "\n", + " Parámetros\n", + " ----------\n", + " prefijo : string\n", + " Srta, Sra, Sr\n", + " appelido : string\n", + " Apellido de un visitante\n", + " edad : entero\n", + " Edad de un visitante\n", + "\n", + " Retorna\n", + " -------\n", + " string\n", + " Mensaje que contiene información del visitante y su elegibilidad\n", + " \"\"\"\n", + "\n", + " # --- verificando tipos de parámetros ---\n", + "\n", + " # el tipo de prefijo debe ser string\n", + " if not isinstance (prefijo, str):\n", + " raise TypeError (\"prefijo debe ser una cadena de texto\")\n", + "\n", + " # el tipo de last_name debe ser string\n", + " if not isinstance (appelido, str):\n", + " raise TypeError (\"last_name debe ser una cadena de texto\")\n", + "\n", + " # el tipo de edad debe ser entero\n", + " if not isinstance (edad, int):\n", + " raise TypeError (\"edad debe ser un entero\")\n", + "\n", + "\n", + " # --- verificando valores de parámetros ---\n", + "\n", + " # prefijo debe ser Srta, Sra, o Sr\n", + " if prefijo not in [\"Srta\", \"Sra\", \"Sr\"]:\n", + " raise ValueError (\"prefijo debe ser Srta, Sra, o Sr\")\n", + "\n", + " # last_name debe contener solo caracteres\n", + " if not appelido.isalpha():\n", + " raise ValueError (\"last_name debe contener solo letras\")\n", + "\n", + " # edad tiene que estar entre 0 y 125\n", + " if edad < 0 or edad > 125:\n", + " raise ValueError (\"edad debe estar entre 0 y 125\")\n", + "\n", + "\n", + " # --- retornando salida ---\n", + "\n", + " if edad >= 65:\n", + " return prefijo + \". \" + appelido + \", usted es elegible para una entrada gratuita al museo porque tiene \" + str(edad) + \" años\"\n", + " else:\n", + " return prefijo + \". \" + appelido + \", usted no es elegible para una entrada gratuita al museo porque tiene \" + str(edad) + \" años\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Llama a la función comprobando los *tipos* de parámetros:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando tipo de prefijo\n", + "mensaje = entrada_gratuita_mueso(1, \"Holmes\", 66)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando tipo de last_name\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", 1.2, 66)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando tipo de edad\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", \"Holmes\", \"Hola\")\n", + "print (mensaje)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Llama a la función comprobando *valores* de parámetros:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando valor de prefijo\n", + "mensaje = entrada_gratuita_mueso(\"Dr\", \"Holmes\", 66)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando valor de last_name\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", \"82\", 66)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# verificando valor de edad\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", \"Holmes\", 130)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "- Llama a la función probando los dos posibles retornos:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# persona es elegible\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", \"Holmes\", 66)\n", + "print (mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# persona no es elegible\n", + "mensaje = entrada_gratuita_mueso(\"Sra\", \"Choi\", 38)\n", + "print (mensaje)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.2" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} \ No newline at end of file diff --git a/31_recursion.ipynb b/31_recursion.ipynb index b1131e0..a30c008 100644 --- a/31_recursion.ipynb +++ b/31_recursion.ipynb @@ -4,12 +4,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 31. Factorials\n", + "# 31. Factoriales\n", "\n", - "## Recursive functions\n", + "## Funciones recursivas\n", "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia de narrativa: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia de código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", "\n", "---" ] @@ -18,7 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Write a function that calculates the factorial of a given integer using a for loop:" + "- Escribe una función que calcule el factorial de un número entero dado utilizando un bucle for:" ] }, { @@ -28,31 +28,31 @@ "outputs": [], "source": [ "def factorial_for (n):\n", - " \"\"\"Calculates the factorial of a given integer using a for loop\n", + " \"\"\"Calcula el factorial de un número entero dado utilizando un bucle for\n", "\n", - " Parameters\n", + " Parámetros\n", " ----------\n", - " n : integer\n", - " The input integer \n", + " n : entero\n", + " El número entero de entrada\n", "\n", - " Returns\n", + " Retorna\n", " -------\n", - " factorial : integer \n", - " The factorial of the input integer\n", + " factorial : entero\n", + " El factorial del número entero de entrada\n", " \"\"\"\n", "\n", - " # initialize the result to one\n", + " # inicializar el resultado en uno\n", " factorial = 1\n", "\n", - " # for each integer between 2 and the input integer\n", + " # para cada entero entre 2 y el número entero de entrada\n", " for i in range (2, n+1):\n", - " # multiply the current result for the current integer \n", + " # multiplicar el resultado actual por el entero actual\n", " factorial *= i\n", "\n", - " # return the result\n", + " # retornar el resultado\n", " return factorial\n", "\n", - "# call the function\n", + "# llamar a la función\n", "fact = factorial_for (4)\n", "print (fact)" ] @@ -61,7 +61,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Compare the previous iterative function with the following recursive function:" + "- Compara la función iterativa anterior con la siguiente función recursiva:" ] }, { @@ -71,29 +71,29 @@ "outputs": [], "source": [ "def factorial_rec (n):\n", - " \"\"\"Calculates the factorial of a given integer using recursion\n", + " \"\"\"Calcula el factorial de un número entero dado utilizando recursión\n", "\n", - " Parameters\n", + " Parámetros\n", " ----------\n", - " n : integer\n", - " The input integer \n", + " n : entero\n", + " El número entero de entrada\n", "\n", - " Returns\n", + " Retorna\n", " -------\n", - " integer \n", - " The factorial of the input integer\n", + " entero\n", + " El factorial del número entero de entrada\n", " \"\"\"\n", - " \n", - " # if n is greater than 1\n", - " if n > 1: \n", - " # execute the recursion\n", + "\n", + " # si n es mayor que 1\n", + " if n > 1:\n", + " # ejecutar la recursión\n", " return factorial_rec(n-1) * n\n", - " # otherwise\n", - " else: \n", - " # return 1\n", - " return 1 \n", + " # de lo contrario\n", + " else:\n", + " # retornar 1\n", + " return 1\n", "\n", - "# call the function\n", + "# llamar a la función\n", "fact = factorial_rec (4)\n", "print (fact)" ] From efb41fec57b3500f0e2b196c05c1d15c34177cbd Mon Sep 17 00:00:00 2001 From: Nick Chomey Date: Tue, 11 Mar 2025 10:37:12 -0600 Subject: [PATCH 24/28] translate and update readme --- README.md | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1db9309..f8025e1 100644 --- a/README.md +++ b/README.md @@ -74,22 +74,45 @@ Haz clic en el botón verde `< > Code` en la parte superior derecha de esta pág
*Diccionarios* 25. [x] [Viaje a Suiza](25_dictionary_list.ipynb)
*Diccionario con listas como valores* -26. [ ] Counting, compressing, and sorting -27. [ ] Overview of strings +26. [x] [Conteo, compresión y ordenamiento](26_count_compress_sort.ipynb) +
*Contar, comprimir y ordenar datos* +27. [x] [Resumen de cadenas de caracteres](27_string_overview.ipynb) +
*Visión general de las cadenas* ### PARTE 8: FUNCIONES -28. [ ] Stationary for a party -29. [ ] Username and password -30. [ ] People's age and odd numbers -31. [ ] Factorials -32. [ ] Jupyter notebooks and modules +28. [x] [Papelería para una fiesta](28_functions.ipynb) +
*Funciones* +29. [x] [Nombre de usuario y contraseña](29_input_validation.ipynb) +
*Validación de entrada* +30. [x] [La edad de las personas y números impares](30_return.ipynb) +
*Retorno de valores en funciones* +31. [x] [Factoriales](31_recursion.ipynb) +
*Recursión* + +### PARTE 8: FUNCIONES +28. [x] [Papelería para una fiesta](28_functions.ipynb) +
*Funciones y parámetros* +29. [x] [Nombre de usuario y contraseña](29_input_validation.ipynb) +
*Validación de entrada y variaciones de salida* +30. [x] [La edad de las personas y números impares](30_return.ipynb) +
*Salidas de funciones y diseño modular* +31. [x] [Factoriales](31_recursion.ipynb) +
*Funciones recursivas* +32. [ ] [Cuadernos de Jupyter y módulos](32_jupyter_modules.ipynb) +
*Trabajando con Jupyter Notebook y un IDE* ### PARTE 9: VARIOS -33. [ ] Online shopping -34. [ ] Final Python tricks +33. [ ] [Compras en línea](33_online_shopping.ipynb) +
*Lectura y escritura de archivos de texto* +34. [ ] [Trucos finales de Python](34_final_python_tricks.ipynb) +
*Qué más hay en Python* ### PARTE 10: PROGRAMACIÓN ORIENTADA A OBJETOS -35. [ ] I need a bank account! -36. [ ] Improving a bank account -37. [ ] What if I need a checking account? -38. [ ] I also need a savings account +35. [ ] [¡Necesito una cuenta bancaria!](35_bank_account.ipynb) +
*Clases y objetos* +36. [ ] [Mejorando una cuenta bancaria](36_improving_bank_account.ipynb) +
*Encapsulación* +37. [ ] [¿Y si necesito una cuenta corriente?](37_checking_account.ipynb) +
*Herencia* +38. [ ] [También necesito una cuenta de ahorros](38_savings_account.ipynb) +
*Polimorfismo* From 551ab271700dceae7eda43d417336b815f79dadc Mon Sep 17 00:00:00 2001 From: nickchomey <88559987+nickchomey@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:20:30 -0600 Subject: [PATCH 25/28] Delete main.py --- main.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 main.py diff --git a/main.py b/main.py deleted file mode 100644 index 4b53ea4..0000000 --- a/main.py +++ /dev/null @@ -1,6 +0,0 @@ -def main(): - print("Hello from jupyternotebooksspanish!") - - -if __name__ == "__main__": - main() From c3c4d6b2f0b66a74f720a0e28a82374eab54f959 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Wed, 2 Apr 2025 18:08:23 +0200 Subject: [PATCH 26/28] Chapter 32 --- 32_modules.ipynb | 312 ++++++++++++++++++++++++++++++++++++++++++++++ setup_database.py | 111 +++++++++++++++++ 2 files changed, 423 insertions(+) create mode 100644 32_modules.ipynb create mode 100644 setup_database.py diff --git a/32_modules.ipynb b/32_modules.ipynb new file mode 100644 index 0000000..f07119f --- /dev/null +++ b/32_modules.ipynb @@ -0,0 +1,312 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 32. How can I reuse functions?\n", + "\n", + "## Working with Jupyter Notebooks and Python Modules\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Creating a module\n", + "\n", + "- Learn the steps in Chapter 32!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 2. Importing a module and running a function\n", + " \n", + "- Import the module as is, then call the function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import setup_database\n", + "\n", + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Import a module and create an alias, then call the function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import setup_database as sdb \n", + "\n", + "username = sdb.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Import one single function from a module, then call the function: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from setup_database import create_username \n", + "\n", + "username = create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Import the function from a module and create an alias, then call the function: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from setup_database import create_username as cu\n", + "\n", + "username = cu (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Importing a module from a different folder \n", + "- Restart the kernel, then add the module folder and import the module:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sys\n", + "sys.path.append(\"\") # write the module location in between quotes\n", + "import setup_database" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call the function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. Changing a function in a module and calling it in a Notebook" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Restart the kernel, then call the function *before* the change:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import setup_database\n", + "\n", + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call the function *after* the change:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Restart the kernel, then run autoreload:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call the function *before* the change:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import setup_database\n", + "\n", + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call the function *after* the change:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "username = setup_database.create_username (\"John\", \"Gelb\") \n", + "print (username)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 5. Adding functions to a module " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call `create_password()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "password = setup_database.create_password()\n", + "print (password)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Call `create_database()`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "customers = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]] \n", + "db, n = setup_database.create_database(customers)\n", + "print (\"Database:\", db)\n", + "print (\"Number of customers:\", n) " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/setup_database.py b/setup_database.py new file mode 100644 index 0000000..6e2d2a7 --- /dev/null +++ b/setup_database.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Wed Jan 29 12:25:45 2025 + +@author: serenabonaretti + +This module contains functions to create usernames and passwords +""" + +import random + + +def create_username (first_name, last_name): + """Create a lowercase username made of initial of first name and last name + + Parameters + ---------- + first_name: string + First name of a person + last_name: string + Last name of a person + + Returns + ------- + username: string + Created username + """ + + # concatenate initial of first name and last name + username = first_name[0] + last_name + # make sure username is lowercase + username = username.lower() + + # return username + return username + + +def create_password(): + """Create a password composed of four random integers + + Returns + ------- + password: string + Created password + """ + + # create a random number with four digits + password = str(random.randint(1000,9999)) + + # return password + return password + + +def create_database (customers): + """Creates a database as a dictionary with usernames as keys and passwords as values + + Parameters + ---------- + customers : list of lists + Each sublist contains first name and last name of a customer + + Returns + ------- + db : dictionary + Created database (shorted as db) + n_customers : int + Number of customers in the database + """ + + # initialize dictionary (i.e. database) + db = {} + + # for each customer + for customer in customers: + + # create username + username = create_username (customer[0], customer[1]) + + # create password + password = create_password() + + # add username and password to db + db[username] = password + + # compute number of customers + n_customers = len(db) + + # return dictionary and its length + return db, n_customers + + +if __name__ == "__main__": + + # input to the main function + customers = [["Maria", "Lopez"], ["Julia", "Smith"], ["Mohammed", "Seid"]] + + # create the database + database, number_customers = create_database(customers) + + # print the outputs + print ("Database:", database) + print ("Number of customers:", number_customers) + + + + + + + + \ No newline at end of file From 6981bcc004aeb6d1513b66e320322d891ab476f1 Mon Sep 17 00:00:00 2001 From: Serena Bonaretti Date: Thu, 24 Apr 2025 16:57:11 +0200 Subject: [PATCH 27/28] after publishing ch 33 and 34 --- 33_purchases.txt | 4 + 33_rw_txt_file.ipynb | 259 +++++++++++++++++++++++++++ 34_python_more.ipynb | 404 +++++++++++++++++++++++++++++++++++++++++++ actors.txt | 13 ++ 4 files changed, 680 insertions(+) create mode 100644 33_purchases.txt create mode 100644 33_rw_txt_file.ipynb create mode 100644 34_python_more.ipynb create mode 100644 actors.txt diff --git a/33_purchases.txt b/33_purchases.txt new file mode 100644 index 0000000..a9be8c1 --- /dev/null +++ b/33_purchases.txt @@ -0,0 +1,4 @@ +20.00 +15.74 +19.10 + diff --git a/33_rw_txt_file.ipynb b/33_rw_txt_file.ipynb new file mode 100644 index 0000000..810c403 --- /dev/null +++ b/33_rw_txt_file.ipynb @@ -0,0 +1,259 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 33. Birthday presents\n", + "\n", + "## Reading and writing *.txt* files\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Three of your friends celebrated their birthday this month, and you bought them presents online.\n", + "Now, it’s time to perform a purchase analysis and save it in your records. The purchase amounts\n", + "are in the file *33_purchases.txt*" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 1. Reading a .txt file\n", + "\n", + "- Write a function that reads a `.txt` file containing one number per row and stores the numbers into a list:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def read_txt (file_name_in):\n", + " \"\"\"Reads a .txt file with one number per row and returns them as a list\n", + " \n", + " Parameters\n", + " ----------\n", + " file_name_in: string\n", + " Name of the file to read\n", + " \n", + " Returns\n", + " -------\n", + " numbers : list\n", + " File content in a list of numbers\n", + " \"\"\"\n", + "\n", + " # initialize output\n", + " numbers = []\n", + " \n", + " # open the file\n", + " with open(file_name_in, \"r\") as file:\n", + " \n", + " # read the file\n", + " for line in file:\n", + " print (\"line as read:\", line)\n", + " \n", + " # remove \"\\n\" from line\n", + " line = line.rstrip(\"\\n\")\n", + " print (\"line after stripping:\", line)\n", + " print (\"-----\")\n", + " \n", + " # get only the non-empty lines\n", + " if line != \"\":\n", + " \n", + " # transform the number to float\n", + " number = float(line)\n", + " \n", + " # add to the output list\n", + " numbers.append(number)\n", + " \n", + " # return the output\n", + " return numbers\n", + "\n", + "# call the function and print the output\n", + "purchases = read_txt(\"33_purchases.txt\")\n", + "print (\"purchases:\", purchases)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- More compact alternative:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def read_txt_compact (file_name_in):\n", + " \"\"\"Reads a .txt file containing a column of numbers\n", + " \n", + " Parameters\n", + " ----------\n", + " file_name_in : string\n", + " Name of the file to read\n", + " \n", + " Returns\n", + " -------\n", + " numbers : list\n", + " File content in a list of numbers\n", + " \"\"\"\n", + " \n", + " # open the file\n", + " with open(file_name_in, \"r\") as file:\n", + " \n", + " # read the numbers and transform them into floats\n", + " numbers = [float(number) for number in file.read().split()]\n", + " \n", + " # return the output\n", + " return numbers\n", + "\n", + "# call the function and print the output\n", + "purchases_compact = read_txt_compact(\"33_purchases.txt\")\n", + "print (\"purchases:\", purchases_compact)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. Analyzing the numbers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Write a function that takes a list of numbers as input and returns the minimum, maximum, and sum as separate variables." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calculate_stats(numbers): \n", + " \"\"\"Returning minimum, maximum, and sum of a list of numbers \n", + " \n", + " Parameters\n", + " ----------\n", + " numbers: list \n", + " Contains numbers\n", + " \n", + " Returns\n", + " -------\n", + " minimum : float\n", + " Minimum of the list\n", + " maximum : float \n", + " Maximum of the list\n", + " total : float\n", + " Sum of the list numbers\n", + " \"\"\"\n", + " \n", + " # calculate the minimum\n", + " minimum = min(numbers)\n", + "\n", + " # calculate the maximum\n", + " maximum = max(numbers) \n", + "\n", + " # calculate the sum\n", + " total = sum(numbers)\n", + "\n", + " # return the stats\n", + " return minimum, maximum, total\n", + "\n", + "# call the function\n", + "mn, mx, tot = calculate_stats(purchases)\n", + "print (\"minimum:\", mn)\n", + "print (\"maximum:\", mx)\n", + "print (\"total:\", tot)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Saving the analysis \n", + "\n", + "- Create a function that given minimum, maximum, and total, writes them to file on three consecutive lines, specifying what they represent:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def write_txt(file_name_out, minimum, maximum, total):\n", + " \"\"\"Writing minimum, maximum, and sum to a file\n", + " \n", + " Parameters\n", + " ----------\n", + " file_name_out: string\n", + " Name of the file to write\n", + " minimum: float\n", + " Minimum of the list\n", + " maximum: float \n", + " Maximum of the list\n", + " total: float\n", + " Sum of the numbers in the list\n", + " \"\"\"\n", + " \n", + " # open the file to write\n", + " with open(file_name_out, \"w\") as file:\n", + " \n", + " # write the file content\n", + " file.write (\"minimum: \" + str(minimum) + \"\\n\")\n", + " file.write (\"maximum: \" + str(maximum) + \"\\n\")\n", + " file.write (\"total: \" + str(total))\n", + "\n", + "# call the function\n", + "write_txt(\"33_purchases_stats.txt\", mn, mx, tot) " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/34_python_more.ipynb b/34_python_more.ipynb new file mode 100644 index 0000000..3bdceab --- /dev/null +++ b/34_python_more.ipynb @@ -0,0 +1,404 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 34. What's more in Python?\n", + "\n", + "## Additional types, keywords, built-in functions, and modules\n", + "\n", + "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Data Types" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1.1 Tuples" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following tuple: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "image_size = (256, 256, 3)\n", + "print (image_size)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Calculate how many times 256 is present: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(image_size.count(256))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Compute the position of 3:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(image_size.index(3))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 1.2 Sets" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following set, print it: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cities = {\"Buenos Aires\", \"Prague\", \"Delhi\", \"Delhi\"}\n", + "print (cities)\n", + "print (\"The number of elements is:\", len(cities))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following list: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cities = [\"San Francisco\", \"Melbourne\", \"San Francisco\", \"Milan\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Remove the duplicates:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cities = list(set(cities))\n", + "print (cities)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Given the following lists: " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cities_1 = [\"Santiago\", \"Bangkok\", \"Cairo\", \"Santiago\"]\n", + "cities_2 = [\"Cairo\", \"Cape Town\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Create a new list that contains unique elements of both lists:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "all_cities = list(set(cities_1).union(set(cities_2)))\n", + "print (all_cities)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Create a new list that contains the elements common to both lists:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "common_cities = list(set(cities_1).intersection(set(cities_2)))\n", + "print (common_cities)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "--- \n", + "## 2. Keywords " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 2.1 `lambda`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Here is the regular function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def double_number (number):\n", + " \"\"\"Returns the double of a number\n", + "\n", + " Parameters\n", + " ----------\n", + " number : float\n", + " The input number\n", + "\n", + " Returns\n", + " -------\n", + " float\n", + " The double of the input number\n", + " \"\"\"\n", + " \n", + " return number * 2\n", + " \n", + "print (double_number(5))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Here is the corresponding lambda function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "double_number = lambda number: number * 2 \n", + "print(double_number(5))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 3. Built-in functions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 3.1 `map()`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Double each list element using a lambda function:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numbers = [3,5,7]\n", + "doubles = list(map(double_number, numbers))\n", + "print(doubles)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "## 4. Modules" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Generate a random integer between 1 and 10 twice:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "\n", + "n = random.randint(1,10)\n", + "print (\"n:\", n)\n", + "n = random.randint(1,10)\n", + "print (\"n:\", n)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Generate a random integer between 1 and 10 twice, using a seed number:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "random.seed(18)\n", + "n = random.randint(1,10)\n", + "print (\"n:\", n)\n", + "\n", + "random.seed(18)\n", + "n = random.randint(1,10)\n", + "print (\"n:\", n)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "- Compare the time it takes to create a list with ten, a hundred, and a thousand zeros, using a for loop vs. list replication. What do you think the time difference will be?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import time \n", + "\n", + "# lists lengths\n", + "n_of_elements = [10, 100, 1000]\n", + "\n", + "# for each length\n", + "for n in n_of_elements:\n", + "\n", + " print (\"N. of zeros:\", len(numbers))\n", + " \n", + " # create the list using the for loop\n", + " start = time.time()\n", + " numbers = []\n", + " for _ in range (n):\n", + " numbers.append(0)\n", + " end = time.time()\n", + " print (\"For loop: {:.6f} sec\".format(end-start))\n", + " \n", + " # create the list using replication\n", + " start = time.time()\n", + " numbers = [0]*n\n", + " end = time.time()\n", + " print (\"Self-repl {:.6f} sec\\n\".format(end-start) ) " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/actors.txt b/actors.txt new file mode 100644 index 0000000..9c8cebf --- /dev/null +++ b/actors.txt @@ -0,0 +1,13 @@ +Timothée Chalamet +Julia Roberts +Denzel Washington +Tom Hanks +Morgan Freeman + Audrey Hepburn +Priyanka Chopra + Sandra Bullock +Sean Connery +Jackie Chan + + + From 62b86e6d6375ea6c65dc29a614e58be44a168e7e Mon Sep 17 00:00:00 2001 From: Nick Chomey Date: Mon, 23 Jun 2025 17:10:06 -0600 Subject: [PATCH 28/28] translate 32-34 --- .vscode/settings.json | 11 + 32_modules.ipynb | 241 +++++++++----- 33_purchases_stats.txt | 3 + 33_rw_txt_file.ipynb | 306 ++++++++++-------- 34_python_more.ipynb | 346 ++++++++++++++------- __pycache__/setup_database.cpython-313.pyc | Bin 0 -> 2262 bytes mise.toml | 0 pyproject.toml | 5 + setup_database.py | 171 +++++----- uv.lock | 248 ++++++++------- 10 files changed, 804 insertions(+), 527 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 33_purchases_stats.txt create mode 100644 __pycache__/setup_database.cpython-313.pyc create mode 100644 mise.toml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8312341 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "go.goroot": "/home/nick/.local/share/mise/installs/go/1.24.4", + "debug.javascript.defaultRuntimeExecutable": { + "pwa-node": "/home/nick/.local/share/mise/shims/node" + }, + "go.alternateTools": { + "go": "/home/nick/.local/share/mise/shims/go", + "dlv": "/home/nick/.local/share/mise/shims/dlv", + "gopls": "/home/nick/.local/share/mise/shims/gopls" + } +} \ No newline at end of file diff --git a/32_modules.ipynb b/32_modules.ipynb index f07119f..0b6e60a 100644 --- a/32_modules.ipynb +++ b/32_modules.ipynb @@ -4,12 +4,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 32. How can I reuse functions?\n", + "# 32. ¿Cómo puedo reutilizar funciones?\n", "\n", - "## Working with Jupyter Notebooks and Python Modules\n", + "## Trabajando con Jupyter Notebooks y módulos de Python\n", "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia del texto: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia del código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", "\n", "---" ] @@ -18,9 +18,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 1. Creating a module\n", + "## 1. Creando un módulo\n", "\n", - "- Learn the steps in Chapter 32!" + "- ¡Aprende los pasos en el Capítulo 32!" ] }, { @@ -28,78 +28,110 @@ "metadata": {}, "source": [ "---\n", - "## 2. Importing a module and running a function\n", + "## 2. Importar un módulo y ejecutar una función\n", " \n", "- Import the module as is, then call the function:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ "import setup_database\n", "\n", - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Import a module and create an alias, then call the function:" + "- Importa un módulo y crea un alias, luego llama a la función:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "import setup_database as sdb \n", + "import setup_database as bdd\n", "\n", - "username = sdb.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = bdd.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Import one single function from a module, then call the function: " + "- Importa una sola función de un módulo, luego llama a la función:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "from setup_database import create_username \n", + "from setup_database import crear_usuario\n", "\n", - "username = create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Import the function from a module and create an alias, then call the function: " + "- Importa la función de un módulo y crea un alias, luego llama a la función:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "from setup_database import create_username as cu\n", + "from setup_database import crear_usuario as cu\n", "\n", - "username = cu (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = cu (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { @@ -107,18 +139,18 @@ "metadata": {}, "source": [ "---\n", - "## 3. Importing a module from a different folder \n", - "- Restart the kernel, then add the module folder and import the module:" + "## 3. Importar un módulo desde otra carpeta\n", + "- Reinicia el kernel, luego agrega la carpeta del módulo e importa el módulo:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import sys\n", - "sys.path.append(\"\") # write the module location in between quotes\n", + "sys.path.append(\"\") # escribe la ubicación del módulo entre comillas\n", "import setup_database" ] }, @@ -126,17 +158,25 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Call the function:" + "- Llama a la función:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { @@ -144,55 +184,71 @@ "metadata": {}, "source": [ "---\n", - "## 4. Changing a function in a module and calling it in a Notebook" + "## 4. Cambiar una función en un módulo y llamarla en un Notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Restart the kernel, then call the function *before* the change:" + "- Reinicia el kernel, luego llama a la función *antes* del cambio:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ "import setup_database\n", "\n", - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Call the function *after* the change:" + "- Llama a la función *después* del cambio:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Restart the kernel, then run autoreload:" + "- Reinicia el kernel, luego ejecuta autoreload:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -204,36 +260,52 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Call the function *before* the change:" + "- Llama a la función *antes* del cambio:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ "import setup_database\n", "\n", - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Call the function *after* the change:" + "- Llama a la función *después* del cambio:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "jgelb\n" + ] + } + ], "source": [ - "username = setup_database.create_username (\"John\", \"Gelb\") \n", - "print (username)" + "usuario = setup_database.crear_usuario (\"John\", \"Gelb\")\n", + "print (usuario)" ] }, { @@ -241,49 +313,66 @@ "metadata": {}, "source": [ "--- \n", - "## 5. Adding functions to a module " + "## 5. Agregar funciones a un módulo" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Call `create_password()`:" + "- Llama a `create_password()`:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1899\n" + ] + } + ], "source": [ - "password = setup_database.create_password()\n", - "print (password)" + "contrasena = setup_database.crear_contrasena()\n", + "print (contrasena)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Call `create_database()`:" + "- Llama a `create_database()`:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Base de datos: {'mlopez': '4575', 'jsmith': '1785', 'mseid': '8816'}\n", + "Número de clientes: 3\n" + ] + } + ], "source": [ - "customers = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]] \n", - "db, n = setup_database.create_database(customers)\n", - "print (\"Database:\", db)\n", - "print (\"Number of customers:\", n) " + "clientes = [[\"Maria\", \"Lopez\"], [\"Julia\", \"Smith\"], [\"Mohammed\", \"Seid\"]]\n", + "bdd, n = setup_database.crear_base_de_datos(clientes)\n", + "print (\"Base de datos:\", bdd)\n", + "print (\"Número de clientes:\", n)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -297,7 +386,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.13.5" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/33_purchases_stats.txt b/33_purchases_stats.txt new file mode 100644 index 0000000..e58b70b --- /dev/null +++ b/33_purchases_stats.txt @@ -0,0 +1,3 @@ +mínimo: 15.74 +máximo: 20.0 +total: 54.84 \ No newline at end of file diff --git a/33_rw_txt_file.ipynb b/33_rw_txt_file.ipynb index 810c403..bc6a33b 100644 --- a/33_rw_txt_file.ipynb +++ b/33_rw_txt_file.ipynb @@ -4,12 +4,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 33. Birthday presents\n", + "# 33. Regalos de cumpleaños\n", "\n", - "## Reading and writing *.txt* files\n", + "## Leer y escribir archivos *.txt*\n", "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia del texto: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia del código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", "\n", "---" ] @@ -18,9 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Three of your friends celebrated their birthday this month, and you bought them presents online.\n", - "Now, it’s time to perform a purchase analysis and save it in your records. The purchase amounts\n", - "are in the file *33_purchases.txt*" + "- Tres de tus amigos celebraron su cumpleaños este mes y les compraste regalos en línea. Ahora es momento de analizar las compras y guardarlas en tus registros. Los montos de las compras están en el archivo *33_purchases.txt*" ] }, { @@ -28,102 +26,134 @@ "metadata": {}, "source": [ "---\n", - "## 1. Reading a .txt file\n", + "## 1. Leer un archivo .txt\n", "\n", - "- Write a function that reads a `.txt` file containing one number per row and stores the numbers into a list:" + "- Escribe una función que lea un archivo `.txt` que contenga un número por fila y almacene los números en una lista:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "línea leída: 20.00\n", + "\n", + "línea sin salto: 20.00\n", + "-----\n", + "línea leída: 15.74 \n", + "\n", + "línea sin salto: 15.74 \n", + "-----\n", + "línea leída: 19.10\n", + "\n", + "línea sin salto: 19.10\n", + "-----\n", + "línea leída: \n", + "\n", + "línea sin salto: \n", + "-----\n", + "compras: [20.0, 15.74, 19.1]\n" + ] + } + ], "source": [ - "def read_txt (file_name_in):\n", - " \"\"\"Reads a .txt file with one number per row and returns them as a list\n", - " \n", - " Parameters\n", + "def leer_txt (nombre_archivo):\n", + " \"\"\"Lee un archivo .txt con un número por fila y los devuelve como una lista\n", + "\n", + " Parámetros\n", " ----------\n", - " file_name_in: string\n", - " Name of the file to read\n", - " \n", - " Returns\n", + " nombre_archivo: string\n", + " Nombre del archivo a leer\n", + "\n", + " Retorna\n", " -------\n", - " numbers : list\n", - " File content in a list of numbers\n", + " numeros : list\n", + " Contenido del archivo en una lista de números\n", " \"\"\"\n", "\n", - " # initialize output\n", - " numbers = []\n", - " \n", - " # open the file\n", - " with open(file_name_in, \"r\") as file:\n", - " \n", - " # read the file\n", - " for line in file:\n", - " print (\"line as read:\", line)\n", - " \n", - " # remove \"\\n\" from line\n", - " line = line.rstrip(\"\\n\")\n", - " print (\"line after stripping:\", line)\n", + " # inicializar salida\n", + " numeros = []\n", + "\n", + " # abrir el archivo\n", + " with open(nombre_archivo, \"r\") as archivo:\n", + "\n", + " # leer el archivo\n", + " for linea in archivo:\n", + " print (\"línea leída:\", linea)\n", + "\n", + " # quitar \"\\n\" de la línea\n", + " linea = linea.rstrip(\"\\n\")\n", + " print (\"línea sin salto:\", linea)\n", " print (\"-----\")\n", - " \n", - " # get only the non-empty lines\n", - " if line != \"\":\n", - " \n", - " # transform the number to float\n", - " number = float(line)\n", - " \n", - " # add to the output list\n", - " numbers.append(number)\n", - " \n", - " # return the output\n", - " return numbers\n", - "\n", - "# call the function and print the output\n", - "purchases = read_txt(\"33_purchases.txt\")\n", - "print (\"purchases:\", purchases)" + "\n", + " # obtener solo las líneas no vacías\n", + " if linea != \"\":\n", + "\n", + " # transformar el número a float\n", + " numero = float(linea)\n", + "\n", + " # agregar a la lista de salida\n", + " numeros.append(numero)\n", + "\n", + " # retornar la salida\n", + " return numeros\n", + "\n", + "# llamar la función e imprimir la salida\n", + "compras = leer_txt(\"33_purchases.txt\")\n", + "print (\"compras:\", compras)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- More compact alternative:" + "- Alternativa más compacta:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "compras: [20.0, 15.74, 19.1]\n" + ] + } + ], "source": [ - "def read_txt_compact (file_name_in):\n", - " \"\"\"Reads a .txt file containing a column of numbers\n", - " \n", - " Parameters\n", + "def leer_txt_compacto (nombre_archivo):\n", + " \"\"\"Lee un archivo .txt que contiene una columna de números\n", + "\n", + " Parámetros\n", " ----------\n", - " file_name_in : string\n", - " Name of the file to read\n", - " \n", - " Returns\n", + " nombre_archivo : string\n", + " Nombre del archivo a leer\n", + "\n", + " Retorna\n", " -------\n", - " numbers : list\n", - " File content in a list of numbers\n", + " numeros : list\n", + " Contenido del archivo en una lista de números\n", " \"\"\"\n", - " \n", - " # open the file\n", - " with open(file_name_in, \"r\") as file:\n", - " \n", - " # read the numbers and transform them into floats\n", - " numbers = [float(number) for number in file.read().split()]\n", - " \n", - " # return the output\n", - " return numbers\n", - "\n", - "# call the function and print the output\n", - "purchases_compact = read_txt_compact(\"33_purchases.txt\")\n", - "print (\"purchases:\", purchases_compact)" + "\n", + " # abrir el archivo\n", + " with open(nombre_archivo, \"r\") as archivo:\n", + "\n", + " # leer los números y transformarlos en floats\n", + " numeros = [float(numero) for numero in archivo.read().split()]\n", + "\n", + " # retornar la salida\n", + " return numeros\n", + "\n", + "# llamar la función e imprimir la salida\n", + "compras_compacto = leer_txt_compacto(\"33_purchases.txt\")\n", + "print (\"compras:\", compras_compacto)" ] }, { @@ -131,56 +161,66 @@ "metadata": {}, "source": [ "--- \n", - "## 2. Analyzing the numbers" + "## 2. Analizando los números" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Write a function that takes a list of numbers as input and returns the minimum, maximum, and sum as separate variables." + "- Escribe una función que tome una lista de números como entrada y devuelva el mínimo, máximo y suma como variables separadas." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mínimo: 15.74\n", + "máximo: 20.0\n", + "total: 54.84\n" + ] + } + ], "source": [ - "def calculate_stats(numbers): \n", - " \"\"\"Returning minimum, maximum, and sum of a list of numbers \n", - " \n", - " Parameters\n", + "def calcular_estadisticas(numeros):\n", + " \"\"\"Devuelve el mínimo, máximo y suma de una lista de números\n", + "\n", + " Parámetros\n", " ----------\n", - " numbers: list \n", - " Contains numbers\n", - " \n", - " Returns\n", + " numeros: list\n", + " Contiene números\n", + "\n", + " Retorna\n", " -------\n", - " minimum : float\n", - " Minimum of the list\n", - " maximum : float \n", - " Maximum of the list\n", + " minimo : float\n", + " Mínimo de la lista\n", + " maximo : float\n", + " Máximo de la lista\n", " total : float\n", - " Sum of the list numbers\n", + " Suma de los números de la lista\n", " \"\"\"\n", - " \n", - " # calculate the minimum\n", - " minimum = min(numbers)\n", "\n", - " # calculate the maximum\n", - " maximum = max(numbers) \n", + " # calcular el mínimo\n", + " minimo = min(numeros)\n", + "\n", + " # calcular el máximo\n", + " maximo = max(numeros)\n", "\n", - " # calculate the sum\n", - " total = sum(numbers)\n", + " # calcular la suma\n", + " total = sum(numeros)\n", "\n", - " # return the stats\n", - " return minimum, maximum, total\n", + " # retornar los resultados\n", + " return minimo, maximo, total\n", "\n", - "# call the function\n", - "mn, mx, tot = calculate_stats(purchases)\n", - "print (\"minimum:\", mn)\n", - "print (\"maximum:\", mx)\n", + "# llamar la función\n", + "mn, mx, tot = calcular_estadisticas(compras)\n", + "print (\"mínimo:\", mn)\n", + "print (\"máximo:\", mx)\n", "print (\"total:\", tot)" ] }, @@ -189,48 +229,48 @@ "metadata": {}, "source": [ "---\n", - "## 3. Saving the analysis \n", + "## 3. Guardando el análisis\n", "\n", - "- Create a function that given minimum, maximum, and total, writes them to file on three consecutive lines, specifying what they represent:" + "- Crea una función que, dado el mínimo, máximo y total, los escriba en un archivo en tres líneas consecutivas, especificando qué representan:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "def write_txt(file_name_out, minimum, maximum, total):\n", - " \"\"\"Writing minimum, maximum, and sum to a file\n", - " \n", - " Parameters\n", + "def escribir_txt(nombre_archivo, minimo, maximo, total):\n", + " \"\"\"Escribe el mínimo, máximo y suma en un archivo\n", + "\n", + " Parámetros\n", " ----------\n", - " file_name_out: string\n", - " Name of the file to write\n", - " minimum: float\n", - " Minimum of the list\n", - " maximum: float \n", - " Maximum of the list\n", + " nombre_archivo: string\n", + " Nombre del archivo a escribir\n", + " minimo: float\n", + " Mínimo de la lista\n", + " maximo: float\n", + " Máximo de la lista\n", " total: float\n", - " Sum of the numbers in the list\n", + " Suma de los números en la lista\n", " \"\"\"\n", - " \n", - " # open the file to write\n", - " with open(file_name_out, \"w\") as file:\n", - " \n", - " # write the file content\n", - " file.write (\"minimum: \" + str(minimum) + \"\\n\")\n", - " file.write (\"maximum: \" + str(maximum) + \"\\n\")\n", - " file.write (\"total: \" + str(total))\n", - "\n", - "# call the function\n", - "write_txt(\"33_purchases_stats.txt\", mn, mx, tot) " + "\n", + " # abrir el archivo para escribir\n", + " with open(nombre_archivo, \"w\") as archivo:\n", + "\n", + " # escribir el contenido del archivo\n", + " archivo.write (\"mínimo: \" + str(minimo) + \"\\n\")\n", + " archivo.write (\"máximo: \" + str(maximo) + \"\\n\")\n", + " archivo.write (\"total: \" + str(total))\n", + "\n", + "# llamar la función\n", + "escribir_txt(\"33_purchases_stats.txt\", mn, mx, tot)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -244,7 +284,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.13.5" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/34_python_more.ipynb b/34_python_more.ipynb index 3bdceab..88b51e0 100644 --- a/34_python_more.ipynb +++ b/34_python_more.ipynb @@ -4,12 +4,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 34. What's more in Python?\n", + "# 34. ¿Qué más hay en Python?\n", "\n", - "## Additional types, keywords, built-in functions, and modules\n", + "## Tipos adicionales, palabras clave, funciones integradas y módulos\n", "\n", - "[Learn Python with Jupyter](https://learnpythonwithjupyter.com/) by [Serena Bonaretti](https://sbonaretti.github.io/) \n", - "Narrative license: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Code license: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", + "[Aprende Python con Jupyter](https://learnpythonwithjupyter.com/) por [Serena Bonaretti](https://sbonaretti.github.io/) \n", + "Licencia del texto: [CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/2.0/). Licencia del código: [GNU-GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) \n", "\n", "---" ] @@ -18,172 +18,229 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 1. Data Types" + "## 1. Tipos de datos" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### 1.1 Tuples" + "### 1.1 Tuplas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Given the following tuple: " + "- Dada la siguiente tupla:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(256, 256, 3)\n" + ] + } + ], "source": [ - "image_size = (256, 256, 3)\n", - "print (image_size)" + "tamano_imagen = (256, 256, 3)\n", + "print (tamano_imagen)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Calculate how many times 256 is present: " + "- Calcula cuántas veces aparece 256:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], "source": [ - "print(image_size.count(256))" + "print(tamano_imagen.count(256))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Compute the position of 3:" + "- Calcula la posición de 3:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + } + ], "source": [ - "print(image_size.index(3))" + "print(tamano_imagen.index(3))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### 1.2 Sets" + "### 1.2 Conjuntos" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Given the following set, print it: " + "- Dado el siguiente conjunto, imprímelo:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'Praga', 'Delhi', 'Buenos Aires'}\n", + "El número de elementos es: 3\n" + ] + } + ], "source": [ - "cities = {\"Buenos Aires\", \"Prague\", \"Delhi\", \"Delhi\"}\n", - "print (cities)\n", - "print (\"The number of elements is:\", len(cities))" + "ciudades = {\"Buenos Aires\", \"Praga\", \"Delhi\", \"Delhi\"}\n", + "print (ciudades)\n", + "print (\"El número de elementos es:\", len(ciudades))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Given the following list: " + "- Dada la siguiente lista:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "cities = [\"San Francisco\", \"Melbourne\", \"San Francisco\", \"Milan\"]" + "ciudades = [\"San Francisco\", \"Melbourne\", \"San Francisco\", \"Milán\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Remove the duplicates:" + "- Elimina los duplicados:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Milán', 'San Francisco', 'Melbourne']\n" + ] + } + ], "source": [ - "cities = list(set(cities))\n", - "print (cities)" + "ciudades = list(set(ciudades))\n", + "print (ciudades)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Given the following lists: " + "- Dadas las siguientes listas:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ - "cities_1 = [\"Santiago\", \"Bangkok\", \"Cairo\", \"Santiago\"]\n", - "cities_2 = [\"Cairo\", \"Cape Town\"]" + "ciudades_1 = [\"Santiago\", \"Bangkok\", \"El Cairo\", \"Santiago\"]\n", + "ciudades_2 = [\"El Cairo\", \"Ciudad del Cabo\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Create a new list that contains unique elements of both lists:" + "- Crea una nueva lista que contenga los elementos únicos de ambas listas:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['El Cairo', 'Bangkok', 'Santiago', 'Ciudad del Cabo']\n" + ] + } + ], "source": [ - "all_cities = list(set(cities_1).union(set(cities_2)))\n", - "print (all_cities)" + "todas_las_ciudades = list(set(ciudades_1).union(set(ciudades_2)))\n", + "print (todas_las_ciudades)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Create a new list that contains the elements common to both lists:" + "- Crea una nueva lista que contenga los elementos comunes a ambas listas:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['El Cairo']\n" + ] + } + ], "source": [ - "common_cities = list(set(cities_1).intersection(set(cities_2)))\n", - "print (common_cities)" + "ciudades_comunes = list(set(ciudades_1).intersection(set(ciudades_2)))\n", + "print (ciudades_comunes)" ] }, { @@ -191,13 +248,15 @@ "metadata": {}, "source": [ "--- \n", - "## 2. Keywords " + "## 2. Palabras clave" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ + "### 2.1 `lambda`\n", + "\n", "### 2.1 `lambda`" ] }, @@ -205,49 +264,65 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Here is the regular function:" + "- Aquí está la función regular:" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def double_number (number):\n", - " \"\"\"Returns the double of a number\n", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "def duplicar_numero (numero):\n", + " \"\"\"Devuelve el doble de un número\n", "\n", - " Parameters\n", + " Parámetros\n", " ----------\n", - " number : float\n", - " The input number\n", + " numero : float\n", + " El número de entrada\n", "\n", - " Returns\n", + " Retorna\n", " -------\n", " float\n", - " The double of the input number\n", + " El doble del número de entrada\n", " \"\"\"\n", - " \n", - " return number * 2\n", - " \n", - "print (double_number(5))" + "\n", + " return numero * 2\n", + "\n", + "print (duplicar_numero(5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Here is the corresponding lambda function:" + "- Aquí está la función lambda correspondiente:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], "source": [ - "double_number = lambda number: number * 2 \n", - "print(double_number(5))" + "duplicar_numero = lambda numero: numero * 2\n", + "print(duplicar_numero(5))" ] }, { @@ -255,7 +330,7 @@ "metadata": {}, "source": [ "---\n", - "## 3. Built-in functions" + "## 3. Funciones integradas" ] }, { @@ -269,18 +344,26 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Double each list element using a lambda function:" + "- Duplica cada elemento de la lista usando una función lambda:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[6, 10, 14]\n" + ] + } + ], "source": [ - "numbers = [3,5,7]\n", - "doubles = list(map(double_number, numbers))\n", - "print(doubles)" + "numeros = [3,5,7]\n", + "dobles = list(map(duplicar_numero, numeros))\n", + "print(dobles)" ] }, { @@ -288,21 +371,30 @@ "metadata": {}, "source": [ "---\n", - "## 4. Modules" + "## 4. Módulos" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "- Generate a random integer between 1 and 10 twice:" + "- Genera un número entero aleatorio entre 1 y 10 dos veces:" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "n: 1\n", + "n: 5\n" + ] + } + ], "source": [ "import random\n", "\n", @@ -316,15 +408,26 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Generate a random integer between 1 and 10 twice, using a seed number:" + "- Genera un número entero aleatorio entre 1 y 10 dos veces, usando una semilla:" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "n: 3\n", + "n: 3\n" + ] + } + ], "source": [ + "import random\n", + "\n", "random.seed(18)\n", "n = random.randint(1,10)\n", "print (\"n:\", n)\n", @@ -338,44 +441,63 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- Compare the time it takes to create a list with ten, a hundred, and a thousand zeros, using a for loop vs. list replication. What do you think the time difference will be?" + "- Compara el tiempo que toma crear una lista con diez, cien y mil ceros, usando un bucle for vs. replicación de listas. ¿Qué crees que pasará con la diferencia de tiempo?" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import time \n", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "N. de ceros: 3\n", + "Bucle for: 0.000005 seg\n", + "Replicación: 0.000003 seg\n", + "\n", + "N. de ceros: 10\n", + "Bucle for: 0.000006 seg\n", + "Replicación: 0.000001 seg\n", + "\n", + "N. de ceros: 100\n", + "Bucle for: 0.000035 seg\n", + "Replicación: 0.000001 seg\n", + "\n" + ] + } + ], + "source": [ + "import time\n", + "\n", + "# longitudes de listas\n", + "n_elementos = [10, 100, 1000]\n", "\n", - "# lists lengths\n", - "n_of_elements = [10, 100, 1000]\n", + "# para cada longitud\n", + "for n in n_elementos:\n", "\n", - "# for each length\n", - "for n in n_of_elements:\n", + " print (\"N. de ceros:\", len(numeros))\n", "\n", - " print (\"N. of zeros:\", len(numbers))\n", - " \n", - " # create the list using the for loop\n", - " start = time.time()\n", - " numbers = []\n", + " # crear la lista usando el bucle for\n", + " inicio = time.time()\n", + " numeros = []\n", " for _ in range (n):\n", - " numbers.append(0)\n", - " end = time.time()\n", - " print (\"For loop: {:.6f} sec\".format(end-start))\n", - " \n", - " # create the list using replication\n", - " start = time.time()\n", - " numbers = [0]*n\n", - " end = time.time()\n", - " print (\"Self-repl {:.6f} sec\\n\".format(end-start) ) " + " numeros.append(0)\n", + " fin = time.time()\n", + " print (\"Bucle for: {:.6f} seg\".format(fin-inicio))\n", + "\n", + " # crear la lista usando replicación\n", + " inicio = time.time()\n", + " numeros = [0]*n\n", + " fin = time.time()\n", + " print (\"Replicación: {:.6f} seg\\n\".format(fin-inicio) )" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -389,7 +511,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.13.5" }, "widgets": { "application/vnd.jupyter.widget-state+json": { diff --git a/__pycache__/setup_database.cpython-313.pyc b/__pycache__/setup_database.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5d9a3dd1eb7edf14fc479369b555954d39263b78 GIT binary patch literal 2262 zcmZ`)&uaY`(Pse`BO)+0P|8lU$letV)iFXCWo5l(}^*7fs#K(X8U*$N$oP38qQ1@l{>XWGo8K5h_BunA{y>@jzq!;(dD=!b;c z3@^tfocOf$6Y=%uBH$S_iCj#O7%T8>orG=`)c~;!jB3(R=sme6Urp{0({7tgM&kVe zRF*>pHi?Vk&`ZMD83pyQYkRGyz8N~i$F~@F1tbl|u|u%!*``e#FmO`aWdRpyP{*+? zrt6;)-g@ZLfHPk|+HHF0zJOW4ZEr!x&}L!?#M$7uLAeh=>Zzlioo5s8|Jtixr2*q$ zlpLccNcPxnpOWG%2!KerK(j1G8HasId0C0HPK;45jUmb=CcXe2B97j#EHal?0EF9> zfHCK&MVBgnXKV${uTABlC)_9;OP>2#P!Ljp8o ztMz!n4w#RLLkSRK1M{y@lX~$;4?9ykoeN%wZvPDzvI~cS93@gfFOkNHXE8U*ihtV+ zfHZyEpD*r=c@Fw$r~~l!OFjh4;0pQsplhO6BWQQ=yKCRy{O0D`N9!XS#bX=0D$Pp* z-_f>OQEK)Ls)>CE$J#p(MqI%Pl$w7LJ?4x4xuHH2cRo}90&mdY*Q4NxQM{j|Espd z`%H%{LCNW@GaVO8#9>g5{x^M12TEB0##QXtf`5^+Zz_hG;^&NqNQaW{}_0*+8 zr!+m-$57><==5OODG1L6`DG=}%~(8<;!v-wMY+^-q`*;8HktA)?B@mOq8+FELN-t^ zpml^f+!3ZYux`OmkjKYh)4TBa26S=$_vf2aTN)a9b0zyqL&JFOjrCm*$Jej_c;(UO z8@o@%tD}cDiicNpknC7#<-)yz7sIgs)fnjdzVYo?N6UqkGi`M|R&$iA*IiBqJkF+YPzgNnFf3wf=4J0y#rnDJ(s};m43hvfd@g4 zFLH5HktFGbrb+775RwL8YNOKd%Za=+`V#M#_HJI5kUFq(XG7ToK<(c1;Bb4Ww03=c zp?%=wlks1!wNG7c7p9vRUufvi=_g|w2hTlIOU>!~XJ8?txBK@#_~KXft>4wYcK^P$ NGry_tY!*=h=syf?Yoh=F literal 0 HcmV?d00001 diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index c7c4005..4918e9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,8 @@ requires-python = ">=3.13" dependencies = [ "ipykernel>=6.29.5", ] + +[dependency-groups] +dev = [ + "ipykernel>=6.29.5", +] diff --git a/setup_database.py b/setup_database.py index 6e2d2a7..75adf00 100644 --- a/setup_database.py +++ b/setup_database.py @@ -1,111 +1,110 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -Created on Wed Jan 29 12:25:45 2025 +Creado el Mié 29 Ene 12:25:45 2025 @author: serenabonaretti -This module contains functions to create usernames and passwords +Este módulo contiene funciones para crear nombres de usuario y contraseñas """ import random -def create_username (first_name, last_name): - """Create a lowercase username made of initial of first name and last name - - Parameters +def crear_usuario (nombre, apellido): + """Crea un nombre de usuario en minúsculas formado por la inicial del nombre y el apellido + + Parámetros ---------- - first_name: string - First name of a person - last_name: string - Last name of a person - - Returns + nombre: string + Nombre de la persona + apellido: string + Apellido de la persona + + Retorna ------- - username: string - Created username + usuario: string + Nombre de usuario creado """ - - # concatenate initial of first name and last name - username = first_name[0] + last_name - # make sure username is lowercase - username = username.lower() - - # return username - return username - - -def create_password(): - """Create a password composed of four random integers - - Returns + + # concatenar inicial del nombre y apellido + usuario = nombre[0] + apellido + # asegurar que el nombre de usuario esté en minúsculas + usuario = usuario.lower() + + # retornar nombre de usuario + return usuario + + +def crear_contrasena(): + """Crea una contraseña compuesta por cuatro dígitos aleatorios + + Retorna ------- - password: string - Created password + contrasena: string + Contraseña creada """ - - # create a random number with four digits - password = str(random.randint(1000,9999)) - - # return password - return password - - -def create_database (customers): - """Creates a database as a dictionary with usernames as keys and passwords as values - - Parameters + + # crear un número aleatorio de cuatro dígitos + contrasena = str(random.randint(1000,9999)) + + # retornar contraseña + return contrasena + + +def crear_base_de_datos (clientes): + """Crea una base de datos como diccionario con nombres de usuario como claves y contraseñas como valores + + Parámetros ---------- - customers : list of lists - Each sublist contains first name and last name of a customer - - Returns + clientes : lista de listas + Cada sublista contiene nombre y apellido de un cliente + + Retorna ------- - db : dictionary - Created database (shorted as db) - n_customers : int - Number of customers in the database + bdd : diccionario + Base de datos creada (abreviado como bdd) + n_clientes : int + Número de clientes en la base de datos """ - - # initialize dictionary (i.e. database) - db = {} - - # for each customer - for customer in customers: - # create username - username = create_username (customer[0], customer[1]) + # inicializar diccionario (es decir, base de datos) + bdd = {} + + # para cada cliente + for cliente in clientes: - # create password - password = create_password() - - # add username and password to db - db[username] = password - - # compute number of customers - n_customers = len(db) + # crear nombre de usuario + usuario = crear_usuario (cliente[0], cliente[1]) - # return dictionary and its length - return db, n_customers + # crear contraseña + contrasena = crear_contrasena() + + # agregar nombre de usuario y contraseña a la base de datos + bdd[usuario] = contrasena + + # calcular número de clientes + n_clientes = len(bdd) + + # retornar diccionario y su longitud + return bdd, n_clientes if __name__ == "__main__": - - # input to the main function - customers = [["Maria", "Lopez"], ["Julia", "Smith"], ["Mohammed", "Seid"]] - - # create the database - database, number_customers = create_database(customers) - - # print the outputs - print ("Database:", database) - print ("Number of customers:", number_customers) - - - - - - - - \ No newline at end of file + + # entrada para la función principal + clientes = [["Maria", "Lopez"], ["Julia", "Smith"], ["Mohammed", "Seid"]] + + # crear la base de datos + base_de_datos, numero_clientes = crear_base_de_datos(clientes) + + # imprimir los resultados + print ("Base de datos:", base_de_datos) + print ("Número de clientes:", numero_clientes) + + + + + + + diff --git a/uv.lock b/uv.lock index a251a47..6eaaf5a 100644 --- a/uv.lock +++ b/uv.lock @@ -1,23 +1,23 @@ version = 1 -revision = 1 +revision = 2 requires-python = ">=3.13" [[package]] name = "appnope" version = "0.1.4" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170 } +sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170, upload-time = "2024-02-06T09:43:11.258Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321 }, + { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321, upload-time = "2024-02-06T09:43:09.663Z" }, ] [[package]] name = "asttokens" version = "3.0.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/4a/e7/82da0a03e7ba5141f05cce0d302e6eed121ae055e0456ca228bf693984bc/asttokens-3.0.0.tar.gz", hash = "sha256:0dcd8baa8d62b0c1d118b399b2ddba3c4aff271d0d7a9e0d4c1681c79035bbc7", size = 61978 } +sdist = { url = "https://files.pythonhosted.org/packages/4a/e7/82da0a03e7ba5141f05cce0d302e6eed121ae055e0456ca228bf693984bc/asttokens-3.0.0.tar.gz", hash = "sha256:0dcd8baa8d62b0c1d118b399b2ddba3c4aff271d0d7a9e0d4c1681c79035bbc7", size = 61978, upload-time = "2024-11-30T04:30:14.439Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/25/8a/c46dcc25341b5bce5472c718902eb3d38600a903b14fa6aeecef3f21a46f/asttokens-3.0.0-py3-none-any.whl", hash = "sha256:e3078351a059199dd5138cb1c706e6430c05eff2ff136af5eb4790f9d28932e2", size = 26918 }, + { url = "https://files.pythonhosted.org/packages/25/8a/c46dcc25341b5bce5472c718902eb3d38600a903b14fa6aeecef3f21a46f/asttokens-3.0.0-py3-none-any.whl", hash = "sha256:e3078351a059199dd5138cb1c706e6430c05eff2ff136af5eb4790f9d28932e2", size = 26918, upload-time = "2024-11-30T04:30:10.946Z" }, ] [[package]] @@ -27,28 +27,28 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pycparser" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824", size = 516621 } +sdist = { url = "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz", hash = "sha256:1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824", size = 516621, upload-time = "2024-09-04T20:45:21.852Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/8d/f8/dd6c246b148639254dad4d6803eb6a54e8c85c6e11ec9df2cffa87571dbe/cffi-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f3a2b4222ce6b60e2e8b337bb9596923045681d71e5a082783484d845390938e", size = 182989 }, - { url = "https://files.pythonhosted.org/packages/8b/f1/672d303ddf17c24fc83afd712316fda78dc6fce1cd53011b839483e1ecc8/cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0984a4925a435b1da406122d4d7968dd861c1385afe3b45ba82b750f229811e2", size = 178802 }, - { url = "https://files.pythonhosted.org/packages/0e/2d/eab2e858a91fdff70533cab61dcff4a1f55ec60425832ddfdc9cd36bc8af/cffi-1.17.1-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d01b12eeeb4427d3110de311e1774046ad344f5b1a7403101878976ecd7a10f3", size = 454792 }, - { url = "https://files.pythonhosted.org/packages/75/b2/fbaec7c4455c604e29388d55599b99ebcc250a60050610fadde58932b7ee/cffi-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:706510fe141c86a69c8ddc029c7910003a17353970cff3b904ff0686a5927683", size = 478893 }, - { url = "https://files.pythonhosted.org/packages/4f/b7/6e4a2162178bf1935c336d4da8a9352cccab4d3a5d7914065490f08c0690/cffi-1.17.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de55b766c7aa2e2a3092c51e0483d700341182f08e67c63630d5b6f200bb28e5", size = 485810 }, - { url = "https://files.pythonhosted.org/packages/c7/8a/1d0e4a9c26e54746dc08c2c6c037889124d4f59dffd853a659fa545f1b40/cffi-1.17.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c59d6e989d07460165cc5ad3c61f9fd8f1b4796eacbd81cee78957842b834af4", size = 471200 }, - { url = "https://files.pythonhosted.org/packages/26/9f/1aab65a6c0db35f43c4d1b4f580e8df53914310afc10ae0397d29d697af4/cffi-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd398dbc6773384a17fe0d3e7eeb8d1a21c2200473ee6806bb5e6a8e62bb73dd", size = 479447 }, - { url = "https://files.pythonhosted.org/packages/5f/e4/fb8b3dd8dc0e98edf1135ff067ae070bb32ef9d509d6cb0f538cd6f7483f/cffi-1.17.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3edc8d958eb099c634dace3c7e16560ae474aa3803a5df240542b305d14e14ed", size = 484358 }, - { url = "https://files.pythonhosted.org/packages/f1/47/d7145bf2dc04684935d57d67dff9d6d795b2ba2796806bb109864be3a151/cffi-1.17.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:72e72408cad3d5419375fc87d289076ee319835bdfa2caad331e377589aebba9", size = 488469 }, - { url = "https://files.pythonhosted.org/packages/bf/ee/f94057fa6426481d663b88637a9a10e859e492c73d0384514a17d78ee205/cffi-1.17.1-cp313-cp313-win32.whl", hash = "sha256:e03eab0a8677fa80d646b5ddece1cbeaf556c313dcfac435ba11f107ba117b5d", size = 172475 }, - { url = "https://files.pythonhosted.org/packages/7c/fc/6a8cb64e5f0324877d503c854da15d76c1e50eb722e320b15345c4d0c6de/cffi-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a", size = 182009 }, + { url = "https://files.pythonhosted.org/packages/8d/f8/dd6c246b148639254dad4d6803eb6a54e8c85c6e11ec9df2cffa87571dbe/cffi-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f3a2b4222ce6b60e2e8b337bb9596923045681d71e5a082783484d845390938e", size = 182989, upload-time = "2024-09-04T20:44:28.956Z" }, + { url = "https://files.pythonhosted.org/packages/8b/f1/672d303ddf17c24fc83afd712316fda78dc6fce1cd53011b839483e1ecc8/cffi-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0984a4925a435b1da406122d4d7968dd861c1385afe3b45ba82b750f229811e2", size = 178802, upload-time = "2024-09-04T20:44:30.289Z" }, + { url = "https://files.pythonhosted.org/packages/0e/2d/eab2e858a91fdff70533cab61dcff4a1f55ec60425832ddfdc9cd36bc8af/cffi-1.17.1-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d01b12eeeb4427d3110de311e1774046ad344f5b1a7403101878976ecd7a10f3", size = 454792, upload-time = "2024-09-04T20:44:32.01Z" }, + { url = "https://files.pythonhosted.org/packages/75/b2/fbaec7c4455c604e29388d55599b99ebcc250a60050610fadde58932b7ee/cffi-1.17.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:706510fe141c86a69c8ddc029c7910003a17353970cff3b904ff0686a5927683", size = 478893, upload-time = "2024-09-04T20:44:33.606Z" }, + { url = "https://files.pythonhosted.org/packages/4f/b7/6e4a2162178bf1935c336d4da8a9352cccab4d3a5d7914065490f08c0690/cffi-1.17.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:de55b766c7aa2e2a3092c51e0483d700341182f08e67c63630d5b6f200bb28e5", size = 485810, upload-time = "2024-09-04T20:44:35.191Z" }, + { url = "https://files.pythonhosted.org/packages/c7/8a/1d0e4a9c26e54746dc08c2c6c037889124d4f59dffd853a659fa545f1b40/cffi-1.17.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c59d6e989d07460165cc5ad3c61f9fd8f1b4796eacbd81cee78957842b834af4", size = 471200, upload-time = "2024-09-04T20:44:36.743Z" }, + { url = "https://files.pythonhosted.org/packages/26/9f/1aab65a6c0db35f43c4d1b4f580e8df53914310afc10ae0397d29d697af4/cffi-1.17.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd398dbc6773384a17fe0d3e7eeb8d1a21c2200473ee6806bb5e6a8e62bb73dd", size = 479447, upload-time = "2024-09-04T20:44:38.492Z" }, + { url = "https://files.pythonhosted.org/packages/5f/e4/fb8b3dd8dc0e98edf1135ff067ae070bb32ef9d509d6cb0f538cd6f7483f/cffi-1.17.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3edc8d958eb099c634dace3c7e16560ae474aa3803a5df240542b305d14e14ed", size = 484358, upload-time = "2024-09-04T20:44:40.046Z" }, + { url = "https://files.pythonhosted.org/packages/f1/47/d7145bf2dc04684935d57d67dff9d6d795b2ba2796806bb109864be3a151/cffi-1.17.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:72e72408cad3d5419375fc87d289076ee319835bdfa2caad331e377589aebba9", size = 488469, upload-time = "2024-09-04T20:44:41.616Z" }, + { url = "https://files.pythonhosted.org/packages/bf/ee/f94057fa6426481d663b88637a9a10e859e492c73d0384514a17d78ee205/cffi-1.17.1-cp313-cp313-win32.whl", hash = "sha256:e03eab0a8677fa80d646b5ddece1cbeaf556c313dcfac435ba11f107ba117b5d", size = 172475, upload-time = "2024-09-04T20:44:43.733Z" }, + { url = "https://files.pythonhosted.org/packages/7c/fc/6a8cb64e5f0324877d503c854da15d76c1e50eb722e320b15345c4d0c6de/cffi-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a", size = 182009, upload-time = "2024-09-04T20:44:45.309Z" }, ] [[package]] name = "colorama" version = "0.4.6" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 }, + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] [[package]] @@ -58,40 +58,40 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e9/a8/fb783cb0abe2b5fded9f55e5703015cdf1c9c85b3669087c538dd15a6a86/comm-0.2.2.tar.gz", hash = "sha256:3fd7a84065306e07bea1773df6eb8282de51ba82f77c72f9c85716ab11fe980e", size = 6210 } +sdist = { url = "https://files.pythonhosted.org/packages/e9/a8/fb783cb0abe2b5fded9f55e5703015cdf1c9c85b3669087c538dd15a6a86/comm-0.2.2.tar.gz", hash = "sha256:3fd7a84065306e07bea1773df6eb8282de51ba82f77c72f9c85716ab11fe980e", size = 6210, upload-time = "2024-03-12T16:53:41.133Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e6/75/49e5bfe642f71f272236b5b2d2691cf915a7283cc0ceda56357b61daa538/comm-0.2.2-py3-none-any.whl", hash = "sha256:e6fb86cb70ff661ee8c9c14e7d36d6de3b4066f1441be4063df9c5009f0a64d3", size = 7180 }, + { url = "https://files.pythonhosted.org/packages/e6/75/49e5bfe642f71f272236b5b2d2691cf915a7283cc0ceda56357b61daa538/comm-0.2.2-py3-none-any.whl", hash = "sha256:e6fb86cb70ff661ee8c9c14e7d36d6de3b4066f1441be4063df9c5009f0a64d3", size = 7180, upload-time = "2024-03-12T16:53:39.226Z" }, ] [[package]] name = "debugpy" version = "1.8.13" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/51/d4/f35f539e11c9344652f362c22413ec5078f677ac71229dc9b4f6f85ccaa3/debugpy-1.8.13.tar.gz", hash = "sha256:837e7bef95bdefba426ae38b9a94821ebdc5bea55627879cd48165c90b9e50ce", size = 1641193 } +sdist = { url = "https://files.pythonhosted.org/packages/51/d4/f35f539e11c9344652f362c22413ec5078f677ac71229dc9b4f6f85ccaa3/debugpy-1.8.13.tar.gz", hash = "sha256:837e7bef95bdefba426ae38b9a94821ebdc5bea55627879cd48165c90b9e50ce", size = 1641193, upload-time = "2025-03-05T01:02:22.807Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/b1/db/ae7cd645c1826aae557cebccbc448f0cc9a818d364efb88f8d80e7a03f41/debugpy-1.8.13-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:31abc9618be4edad0b3e3a85277bc9ab51a2d9f708ead0d99ffb5bb750e18503", size = 2485416 }, - { url = "https://files.pythonhosted.org/packages/ec/ed/db4b10ff3b5bb30fe41d9e86444a08bb6448e4d8265e7768450b8408dd36/debugpy-1.8.13-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0bd87557f97bced5513a74088af0b84982b6ccb2e254b9312e29e8a5c4270eb", size = 4218784 }, - { url = "https://files.pythonhosted.org/packages/82/82/ed81852a8d94086f51664d032d83c7f87cd2b087c6ea70dabec7c1ba813d/debugpy-1.8.13-cp313-cp313-win32.whl", hash = "sha256:5268ae7fdca75f526d04465931cb0bd24577477ff50e8bb03dab90983f4ebd02", size = 5226270 }, - { url = "https://files.pythonhosted.org/packages/15/63/aa92fb341a78ec40f1c414ec7a7885c2ee17032eee00d12cee0cdc502af4/debugpy-1.8.13-cp313-cp313-win_amd64.whl", hash = "sha256:79ce4ed40966c4c1631d0131606b055a5a2f8e430e3f7bf8fd3744b09943e8e8", size = 5268621 }, - { url = "https://files.pythonhosted.org/packages/37/4f/0b65410a08b6452bfd3f7ed6f3610f1a31fb127f46836e82d31797065dcb/debugpy-1.8.13-py2.py3-none-any.whl", hash = "sha256:d4ba115cdd0e3a70942bd562adba9ec8c651fe69ddde2298a1be296fc331906f", size = 5229306 }, + { url = "https://files.pythonhosted.org/packages/b1/db/ae7cd645c1826aae557cebccbc448f0cc9a818d364efb88f8d80e7a03f41/debugpy-1.8.13-cp313-cp313-macosx_14_0_universal2.whl", hash = "sha256:31abc9618be4edad0b3e3a85277bc9ab51a2d9f708ead0d99ffb5bb750e18503", size = 2485416, upload-time = "2025-03-05T01:02:50.558Z" }, + { url = "https://files.pythonhosted.org/packages/ec/ed/db4b10ff3b5bb30fe41d9e86444a08bb6448e4d8265e7768450b8408dd36/debugpy-1.8.13-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0bd87557f97bced5513a74088af0b84982b6ccb2e254b9312e29e8a5c4270eb", size = 4218784, upload-time = "2025-03-05T01:02:53.535Z" }, + { url = "https://files.pythonhosted.org/packages/82/82/ed81852a8d94086f51664d032d83c7f87cd2b087c6ea70dabec7c1ba813d/debugpy-1.8.13-cp313-cp313-win32.whl", hash = "sha256:5268ae7fdca75f526d04465931cb0bd24577477ff50e8bb03dab90983f4ebd02", size = 5226270, upload-time = "2025-03-05T01:02:56.241Z" }, + { url = "https://files.pythonhosted.org/packages/15/63/aa92fb341a78ec40f1c414ec7a7885c2ee17032eee00d12cee0cdc502af4/debugpy-1.8.13-cp313-cp313-win_amd64.whl", hash = "sha256:79ce4ed40966c4c1631d0131606b055a5a2f8e430e3f7bf8fd3744b09943e8e8", size = 5268621, upload-time = "2025-03-05T01:02:57.845Z" }, + { url = "https://files.pythonhosted.org/packages/37/4f/0b65410a08b6452bfd3f7ed6f3610f1a31fb127f46836e82d31797065dcb/debugpy-1.8.13-py2.py3-none-any.whl", hash = "sha256:d4ba115cdd0e3a70942bd562adba9ec8c651fe69ddde2298a1be296fc331906f", size = 5229306, upload-time = "2025-03-05T01:03:16.51Z" }, ] [[package]] name = "decorator" version = "5.2.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/43/fa/6d96a0978d19e17b68d634497769987b16c8f4cd0a7a05048bec693caa6b/decorator-5.2.1.tar.gz", hash = "sha256:65f266143752f734b0a7cc83c46f4618af75b8c5911b00ccb61d0ac9b6da0360", size = 56711 } +sdist = { url = "https://files.pythonhosted.org/packages/43/fa/6d96a0978d19e17b68d634497769987b16c8f4cd0a7a05048bec693caa6b/decorator-5.2.1.tar.gz", hash = "sha256:65f266143752f734b0a7cc83c46f4618af75b8c5911b00ccb61d0ac9b6da0360", size = 56711, upload-time = "2025-02-24T04:41:34.073Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190 }, + { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190, upload-time = "2025-02-24T04:41:32.565Z" }, ] [[package]] name = "executing" version = "2.2.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/91/50/a9d80c47ff289c611ff12e63f7c5d13942c65d68125160cefd768c73e6e4/executing-2.2.0.tar.gz", hash = "sha256:5d108c028108fe2551d1a7b2e8b713341e2cb4fc0aa7dcf966fa4327a5226755", size = 978693 } +sdist = { url = "https://files.pythonhosted.org/packages/91/50/a9d80c47ff289c611ff12e63f7c5d13942c65d68125160cefd768c73e6e4/executing-2.2.0.tar.gz", hash = "sha256:5d108c028108fe2551d1a7b2e8b713341e2cb4fc0aa7dcf966fa4327a5226755", size = 978693, upload-time = "2025-01-22T15:41:29.403Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/7b/8f/c4d9bafc34ad7ad5d8dc16dd1347ee0e507a52c3adb6bfa8887e1c6a26ba/executing-2.2.0-py2.py3-none-any.whl", hash = "sha256:11387150cad388d62750327a53d3339fad4888b39a6fe233c3afbb54ecffd3aa", size = 26702 }, + { url = "https://files.pythonhosted.org/packages/7b/8f/c4d9bafc34ad7ad5d8dc16dd1347ee0e507a52c3adb6bfa8887e1c6a26ba/executing-2.2.0-py2.py3-none-any.whl", hash = "sha256:11387150cad388d62750327a53d3339fad4888b39a6fe233c3afbb54ecffd3aa", size = 26702, upload-time = "2025-01-22T15:41:25.929Z" }, ] [[package]] @@ -113,9 +113,9 @@ dependencies = [ { name = "tornado" }, { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e9/5c/67594cb0c7055dc50814b21731c22a601101ea3b1b50a9a1b090e11f5d0f/ipykernel-6.29.5.tar.gz", hash = "sha256:f093a22c4a40f8828f8e330a9c297cb93dcab13bd9678ded6de8e5cf81c56215", size = 163367 } +sdist = { url = "https://files.pythonhosted.org/packages/e9/5c/67594cb0c7055dc50814b21731c22a601101ea3b1b50a9a1b090e11f5d0f/ipykernel-6.29.5.tar.gz", hash = "sha256:f093a22c4a40f8828f8e330a9c297cb93dcab13bd9678ded6de8e5cf81c56215", size = 163367, upload-time = "2024-07-01T14:07:22.543Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/94/5c/368ae6c01c7628438358e6d337c19b05425727fbb221d2a3c4303c372f42/ipykernel-6.29.5-py3-none-any.whl", hash = "sha256:afdb66ba5aa354b09b91379bac28ae4afebbb30e8b39510c9690afb7a10421b5", size = 117173 }, + { url = "https://files.pythonhosted.org/packages/94/5c/368ae6c01c7628438358e6d337c19b05425727fbb221d2a3c4303c372f42/ipykernel-6.29.5-py3-none-any.whl", hash = "sha256:afdb66ba5aa354b09b91379bac28ae4afebbb30e8b39510c9690afb7a10421b5", size = 117173, upload-time = "2024-07-01T14:07:19.603Z" }, ] [[package]] @@ -134,9 +134,9 @@ dependencies = [ { name = "stack-data" }, { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/7d/ce/012a0f40ca58a966f87a6e894d6828e2817657cbdf522b02a5d3a87d92ce/ipython-9.0.2.tar.gz", hash = "sha256:ec7b479e3e5656bf4f58c652c120494df1820f4f28f522fb7ca09e213c2aab52", size = 4366102 } +sdist = { url = "https://files.pythonhosted.org/packages/7d/ce/012a0f40ca58a966f87a6e894d6828e2817657cbdf522b02a5d3a87d92ce/ipython-9.0.2.tar.gz", hash = "sha256:ec7b479e3e5656bf4f58c652c120494df1820f4f28f522fb7ca09e213c2aab52", size = 4366102, upload-time = "2025-03-08T15:04:52.885Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/20/3a/917cb9e72f4e1a4ea13c862533205ae1319bd664119189ee5cc9e4e95ebf/ipython-9.0.2-py3-none-any.whl", hash = "sha256:143ef3ea6fb1e1bffb4c74b114051de653ffb7737a3f7ab1670e657ca6ae8c44", size = 600524 }, + { url = "https://files.pythonhosted.org/packages/20/3a/917cb9e72f4e1a4ea13c862533205ae1319bd664119189ee5cc9e4e95ebf/ipython-9.0.2-py3-none-any.whl", hash = "sha256:143ef3ea6fb1e1bffb4c74b114051de653ffb7737a3f7ab1670e657ca6ae8c44", size = 600524, upload-time = "2025-03-08T15:04:50.667Z" }, ] [[package]] @@ -146,9 +146,9 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pygments" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393 } +sdist = { url = "https://files.pythonhosted.org/packages/ef/4c/5dd1d8af08107f88c7f741ead7a40854b8ac24ddf9ae850afbcf698aa552/ipython_pygments_lexers-1.1.1.tar.gz", hash = "sha256:09c0138009e56b6854f9535736f4171d855c8c08a563a0dcd8022f78355c7e81", size = 8393, upload-time = "2025-01-17T11:24:34.505Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d9/33/1f075bf72b0b747cb3288d011319aaf64083cf2efef8354174e3ed4540e2/ipython_pygments_lexers-1.1.1-py3-none-any.whl", hash = "sha256:a9462224a505ade19a605f71f8fa63c2048833ce50abc86768a0d81d876dc81c", size = 8074 }, + { url = "https://files.pythonhosted.org/packages/d9/33/1f075bf72b0b747cb3288d011319aaf64083cf2efef8354174e3ed4540e2/ipython_pygments_lexers-1.1.1-py3-none-any.whl", hash = "sha256:a9462224a505ade19a605f71f8fa63c2048833ce50abc86768a0d81d876dc81c", size = 8074, upload-time = "2025-01-17T11:24:33.271Z" }, ] [[package]] @@ -158,9 +158,9 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "parso" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/72/3a/79a912fbd4d8dd6fbb02bf69afd3bb72cf0c729bb3063c6f4498603db17a/jedi-0.19.2.tar.gz", hash = "sha256:4770dc3de41bde3966b02eb84fbcf557fb33cce26ad23da12c742fb50ecb11f0", size = 1231287 } +sdist = { url = "https://files.pythonhosted.org/packages/72/3a/79a912fbd4d8dd6fbb02bf69afd3bb72cf0c729bb3063c6f4498603db17a/jedi-0.19.2.tar.gz", hash = "sha256:4770dc3de41bde3966b02eb84fbcf557fb33cce26ad23da12c742fb50ecb11f0", size = 1231287, upload-time = "2024-11-11T01:41:42.873Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl", hash = "sha256:a8ef22bde8490f57fe5c7681a3c83cb58874daf72b4784de3cce5b6ef6edb5b9", size = 1572278 }, + { url = "https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl", hash = "sha256:a8ef22bde8490f57fe5c7681a3c83cb58874daf72b4784de3cce5b6ef6edb5b9", size = 1572278, upload-time = "2024-11-11T01:41:40.175Z" }, ] [[package]] @@ -174,9 +174,9 @@ dependencies = [ { name = "tornado" }, { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/71/22/bf9f12fdaeae18019a468b68952a60fe6dbab5d67cd2a103cac7659b41ca/jupyter_client-8.6.3.tar.gz", hash = "sha256:35b3a0947c4a6e9d589eb97d7d4cd5e90f910ee73101611f01283732bd6d9419", size = 342019 } +sdist = { url = "https://files.pythonhosted.org/packages/71/22/bf9f12fdaeae18019a468b68952a60fe6dbab5d67cd2a103cac7659b41ca/jupyter_client-8.6.3.tar.gz", hash = "sha256:35b3a0947c4a6e9d589eb97d7d4cd5e90f910ee73101611f01283732bd6d9419", size = 342019, upload-time = "2024-09-17T10:44:17.613Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/11/85/b0394e0b6fcccd2c1eeefc230978a6f8cb0c5df1e4cd3e7625735a0d7d1e/jupyter_client-8.6.3-py3-none-any.whl", hash = "sha256:e8a19cc986cc45905ac3362915f410f3af85424b4c0905e94fa5f2cb08e8f23f", size = 106105 }, + { url = "https://files.pythonhosted.org/packages/11/85/b0394e0b6fcccd2c1eeefc230978a6f8cb0c5df1e4cd3e7625735a0d7d1e/jupyter_client-8.6.3-py3-none-any.whl", hash = "sha256:e8a19cc986cc45905ac3362915f410f3af85424b4c0905e94fa5f2cb08e8f23f", size = 106105, upload-time = "2024-09-17T10:44:15.218Z" }, ] [[package]] @@ -188,9 +188,9 @@ dependencies = [ { name = "pywin32", marker = "platform_python_implementation != 'PyPy' and sys_platform == 'win32'" }, { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/00/11/b56381fa6c3f4cc5d2cf54a7dbf98ad9aa0b339ef7a601d6053538b079a7/jupyter_core-5.7.2.tar.gz", hash = "sha256:aa5f8d32bbf6b431ac830496da7392035d6f61b4f54872f15c4bd2a9c3f536d9", size = 87629 } +sdist = { url = "https://files.pythonhosted.org/packages/00/11/b56381fa6c3f4cc5d2cf54a7dbf98ad9aa0b339ef7a601d6053538b079a7/jupyter_core-5.7.2.tar.gz", hash = "sha256:aa5f8d32bbf6b431ac830496da7392035d6f61b4f54872f15c4bd2a9c3f536d9", size = 87629, upload-time = "2024-03-12T12:37:35.652Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c9/fb/108ecd1fe961941959ad0ee4e12ee7b8b1477247f30b1fdfd83ceaf017f0/jupyter_core-5.7.2-py3-none-any.whl", hash = "sha256:4f7315d2f6b4bcf2e3e7cb6e46772eba760ae459cd1f59d29eb57b0a01bd7409", size = 28965 }, + { url = "https://files.pythonhosted.org/packages/c9/fb/108ecd1fe961941959ad0ee4e12ee7b8b1477247f30b1fdfd83ceaf017f0/jupyter_core-5.7.2-py3-none-any.whl", hash = "sha256:4f7315d2f6b4bcf2e3e7cb6e46772eba760ae459cd1f59d29eb57b0a01bd7409", size = 28965, upload-time = "2024-03-12T12:37:32.36Z" }, ] [[package]] @@ -201,9 +201,17 @@ dependencies = [ { name = "ipykernel" }, ] +[package.dev-dependencies] +dev = [ + { name = "ipykernel" }, +] + [package.metadata] requires-dist = [{ name = "ipykernel", specifier = ">=6.29.5" }] +[package.metadata.requires-dev] +dev = [{ name = "ipykernel", specifier = ">=6.29.5" }] + [[package]] name = "matplotlib-inline" version = "0.1.7" @@ -211,36 +219,36 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "traitlets" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/99/5b/a36a337438a14116b16480db471ad061c36c3694df7c2084a0da7ba538b7/matplotlib_inline-0.1.7.tar.gz", hash = "sha256:8423b23ec666be3d16e16b60bdd8ac4e86e840ebd1dd11a30b9f117f2fa0ab90", size = 8159 } +sdist = { url = "https://files.pythonhosted.org/packages/99/5b/a36a337438a14116b16480db471ad061c36c3694df7c2084a0da7ba538b7/matplotlib_inline-0.1.7.tar.gz", hash = "sha256:8423b23ec666be3d16e16b60bdd8ac4e86e840ebd1dd11a30b9f117f2fa0ab90", size = 8159, upload-time = "2024-04-15T13:44:44.803Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/8f/8e/9ad090d3553c280a8060fbf6e24dc1c0c29704ee7d1c372f0c174aa59285/matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca", size = 9899 }, + { url = "https://files.pythonhosted.org/packages/8f/8e/9ad090d3553c280a8060fbf6e24dc1c0c29704ee7d1c372f0c174aa59285/matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca", size = 9899, upload-time = "2024-04-15T13:44:43.265Z" }, ] [[package]] name = "nest-asyncio" version = "1.6.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/83/f8/51569ac65d696c8ecbee95938f89d4abf00f47d58d48f6fbabfe8f0baefe/nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe", size = 7418 } +sdist = { url = "https://files.pythonhosted.org/packages/83/f8/51569ac65d696c8ecbee95938f89d4abf00f47d58d48f6fbabfe8f0baefe/nest_asyncio-1.6.0.tar.gz", hash = "sha256:6f172d5449aca15afd6c646851f4e31e02c598d553a667e38cafa997cfec55fe", size = 7418, upload-time = "2024-01-21T14:25:19.227Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/a0/c4/c2971a3ba4c6103a3d10c4b0f24f461ddc027f0f09763220cf35ca1401b3/nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c", size = 5195 }, + { url = "https://files.pythonhosted.org/packages/a0/c4/c2971a3ba4c6103a3d10c4b0f24f461ddc027f0f09763220cf35ca1401b3/nest_asyncio-1.6.0-py3-none-any.whl", hash = "sha256:87af6efd6b5e897c81050477ef65c62e2b2f35d51703cae01aff2905b1852e1c", size = 5195, upload-time = "2024-01-21T14:25:17.223Z" }, ] [[package]] name = "packaging" version = "24.2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950 } +sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950, upload-time = "2024-11-08T09:47:47.202Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451 }, + { url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451, upload-time = "2024-11-08T09:47:44.722Z" }, ] [[package]] name = "parso" version = "0.8.4" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/66/94/68e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d/parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d", size = 400609 } +sdist = { url = "https://files.pythonhosted.org/packages/66/94/68e2e17afaa9169cf6412ab0f28623903be73d1b32e208d9e8e541bb086d/parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d", size = 400609, upload-time = "2024-04-05T09:43:55.897Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/c6/ac/dac4a63f978e4dcb3c6d3a78c4d8e0192a113d288502a1216950c41b1027/parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18", size = 103650 }, + { url = "https://files.pythonhosted.org/packages/c6/ac/dac4a63f978e4dcb3c6d3a78c4d8e0192a113d288502a1216950c41b1027/parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18", size = 103650, upload-time = "2024-04-05T09:43:53.299Z" }, ] [[package]] @@ -250,18 +258,18 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "ptyprocess" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450 } +sdist = { url = "https://files.pythonhosted.org/packages/42/92/cc564bf6381ff43ce1f4d06852fc19a2f11d180f23dc32d9588bee2f149d/pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f", size = 166450, upload-time = "2023-11-25T09:07:26.339Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772 }, + { url = "https://files.pythonhosted.org/packages/9e/c3/059298687310d527a58bb01f3b1965787ee3b40dce76752eda8b44e9a2c5/pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523", size = 63772, upload-time = "2023-11-25T06:56:14.81Z" }, ] [[package]] name = "platformdirs" version = "4.3.6" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/13/fc/128cc9cb8f03208bdbf93d3aa862e16d376844a14f9a0ce5cf4507372de4/platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907", size = 21302 } +sdist = { url = "https://files.pythonhosted.org/packages/13/fc/128cc9cb8f03208bdbf93d3aa862e16d376844a14f9a0ce5cf4507372de4/platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907", size = 21302, upload-time = "2024-09-17T19:06:50.688Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/3c/a6/bc1012356d8ece4d66dd75c4b9fc6c1f6650ddd5991e421177d9f8f671be/platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb", size = 18439 }, + { url = "https://files.pythonhosted.org/packages/3c/a6/bc1012356d8ece4d66dd75c4b9fc6c1f6650ddd5991e421177d9f8f671be/platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb", size = 18439, upload-time = "2024-09-17T19:06:49.212Z" }, ] [[package]] @@ -271,60 +279,60 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "wcwidth" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/a1/e1/bd15cb8ffdcfeeb2bdc215de3c3cffca11408d829e4b8416dcfe71ba8854/prompt_toolkit-3.0.50.tar.gz", hash = "sha256:544748f3860a2623ca5cd6d2795e7a14f3d0e1c3c9728359013f79877fc89bab", size = 429087 } +sdist = { url = "https://files.pythonhosted.org/packages/a1/e1/bd15cb8ffdcfeeb2bdc215de3c3cffca11408d829e4b8416dcfe71ba8854/prompt_toolkit-3.0.50.tar.gz", hash = "sha256:544748f3860a2623ca5cd6d2795e7a14f3d0e1c3c9728359013f79877fc89bab", size = 429087, upload-time = "2025-01-20T15:55:35.072Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e4/ea/d836f008d33151c7a1f62caf3d8dd782e4d15f6a43897f64480c2b8de2ad/prompt_toolkit-3.0.50-py3-none-any.whl", hash = "sha256:9b6427eb19e479d98acff65196a307c555eb567989e6d88ebbb1b509d9779198", size = 387816 }, + { url = "https://files.pythonhosted.org/packages/e4/ea/d836f008d33151c7a1f62caf3d8dd782e4d15f6a43897f64480c2b8de2ad/prompt_toolkit-3.0.50-py3-none-any.whl", hash = "sha256:9b6427eb19e479d98acff65196a307c555eb567989e6d88ebbb1b509d9779198", size = 387816, upload-time = "2025-01-20T15:55:29.98Z" }, ] [[package]] name = "psutil" version = "7.0.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/2a/80/336820c1ad9286a4ded7e845b2eccfcb27851ab8ac6abece774a6ff4d3de/psutil-7.0.0.tar.gz", hash = "sha256:7be9c3eba38beccb6495ea33afd982a44074b78f28c434a1f51cc07fd315c456", size = 497003 } +sdist = { url = "https://files.pythonhosted.org/packages/2a/80/336820c1ad9286a4ded7e845b2eccfcb27851ab8ac6abece774a6ff4d3de/psutil-7.0.0.tar.gz", hash = "sha256:7be9c3eba38beccb6495ea33afd982a44074b78f28c434a1f51cc07fd315c456", size = 497003, upload-time = "2025-02-13T21:54:07.946Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ed/e6/2d26234410f8b8abdbf891c9da62bee396583f713fb9f3325a4760875d22/psutil-7.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25", size = 238051 }, - { url = "https://files.pythonhosted.org/packages/04/8b/30f930733afe425e3cbfc0e1468a30a18942350c1a8816acfade80c005c4/psutil-7.0.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:39db632f6bb862eeccf56660871433e111b6ea58f2caea825571951d4b6aa3da", size = 239535 }, - { url = "https://files.pythonhosted.org/packages/2a/ed/d362e84620dd22876b55389248e522338ed1bf134a5edd3b8231d7207f6d/psutil-7.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fcee592b4c6f146991ca55919ea3d1f8926497a713ed7faaf8225e174581e91", size = 275004 }, - { url = "https://files.pythonhosted.org/packages/bf/b9/b0eb3f3cbcb734d930fdf839431606844a825b23eaf9a6ab371edac8162c/psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b1388a4f6875d7e2aff5c4ca1cc16c545ed41dd8bb596cefea80111db353a34", size = 277986 }, - { url = "https://files.pythonhosted.org/packages/eb/a2/709e0fe2f093556c17fbafda93ac032257242cabcc7ff3369e2cb76a97aa/psutil-7.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5f098451abc2828f7dc6b58d44b532b22f2088f4999a937557b603ce72b1993", size = 279544 }, - { url = "https://files.pythonhosted.org/packages/50/e6/eecf58810b9d12e6427369784efe814a1eec0f492084ce8eb8f4d89d6d61/psutil-7.0.0-cp37-abi3-win32.whl", hash = "sha256:ba3fcef7523064a6c9da440fc4d6bd07da93ac726b5733c29027d7dc95b39d99", size = 241053 }, - { url = "https://files.pythonhosted.org/packages/50/1b/6921afe68c74868b4c9fa424dad3be35b095e16687989ebbb50ce4fceb7c/psutil-7.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:4cf3d4eb1aa9b348dec30105c55cd9b7d4629285735a102beb4441e38db90553", size = 244885 }, + { url = "https://files.pythonhosted.org/packages/ed/e6/2d26234410f8b8abdbf891c9da62bee396583f713fb9f3325a4760875d22/psutil-7.0.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25", size = 238051, upload-time = "2025-02-13T21:54:12.36Z" }, + { url = "https://files.pythonhosted.org/packages/04/8b/30f930733afe425e3cbfc0e1468a30a18942350c1a8816acfade80c005c4/psutil-7.0.0-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:39db632f6bb862eeccf56660871433e111b6ea58f2caea825571951d4b6aa3da", size = 239535, upload-time = "2025-02-13T21:54:16.07Z" }, + { url = "https://files.pythonhosted.org/packages/2a/ed/d362e84620dd22876b55389248e522338ed1bf134a5edd3b8231d7207f6d/psutil-7.0.0-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1fcee592b4c6f146991ca55919ea3d1f8926497a713ed7faaf8225e174581e91", size = 275004, upload-time = "2025-02-13T21:54:18.662Z" }, + { url = "https://files.pythonhosted.org/packages/bf/b9/b0eb3f3cbcb734d930fdf839431606844a825b23eaf9a6ab371edac8162c/psutil-7.0.0-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4b1388a4f6875d7e2aff5c4ca1cc16c545ed41dd8bb596cefea80111db353a34", size = 277986, upload-time = "2025-02-13T21:54:21.811Z" }, + { url = "https://files.pythonhosted.org/packages/eb/a2/709e0fe2f093556c17fbafda93ac032257242cabcc7ff3369e2cb76a97aa/psutil-7.0.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5f098451abc2828f7dc6b58d44b532b22f2088f4999a937557b603ce72b1993", size = 279544, upload-time = "2025-02-13T21:54:24.68Z" }, + { url = "https://files.pythonhosted.org/packages/50/e6/eecf58810b9d12e6427369784efe814a1eec0f492084ce8eb8f4d89d6d61/psutil-7.0.0-cp37-abi3-win32.whl", hash = "sha256:ba3fcef7523064a6c9da440fc4d6bd07da93ac726b5733c29027d7dc95b39d99", size = 241053, upload-time = "2025-02-13T21:54:34.31Z" }, + { url = "https://files.pythonhosted.org/packages/50/1b/6921afe68c74868b4c9fa424dad3be35b095e16687989ebbb50ce4fceb7c/psutil-7.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:4cf3d4eb1aa9b348dec30105c55cd9b7d4629285735a102beb4441e38db90553", size = 244885, upload-time = "2025-02-13T21:54:37.486Z" }, ] [[package]] name = "ptyprocess" version = "0.7.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762 } +sdist = { url = "https://files.pythonhosted.org/packages/20/e5/16ff212c1e452235a90aeb09066144d0c5a6a8c0834397e03f5224495c4e/ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220", size = 70762, upload-time = "2020-12-28T15:15:30.155Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993 }, + { url = "https://files.pythonhosted.org/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35", size = 13993, upload-time = "2020-12-28T15:15:28.35Z" }, ] [[package]] name = "pure-eval" version = "0.2.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/cd/05/0a34433a064256a578f1783a10da6df098ceaa4a57bbeaa96a6c0352786b/pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42", size = 19752 } +sdist = { url = "https://files.pythonhosted.org/packages/cd/05/0a34433a064256a578f1783a10da6df098ceaa4a57bbeaa96a6c0352786b/pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42", size = 19752, upload-time = "2024-07-21T12:58:21.801Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/8e/37/efad0257dc6e593a18957422533ff0f87ede7c9c6ea010a2177d738fb82f/pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0", size = 11842 }, + { url = "https://files.pythonhosted.org/packages/8e/37/efad0257dc6e593a18957422533ff0f87ede7c9c6ea010a2177d738fb82f/pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0", size = 11842, upload-time = "2024-07-21T12:58:20.04Z" }, ] [[package]] name = "pycparser" version = "2.22" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/1d/b2/31537cf4b1ca988837256c910a668b553fceb8f069bedc4b1c826024b52c/pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6", size = 172736 } +sdist = { url = "https://files.pythonhosted.org/packages/1d/b2/31537cf4b1ca988837256c910a668b553fceb8f069bedc4b1c826024b52c/pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6", size = 172736, upload-time = "2024-03-30T13:22:22.564Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/13/a3/a812df4e2dd5696d1f351d58b8fe16a405b234ad2886a0dab9183fb78109/pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc", size = 117552 }, + { url = "https://files.pythonhosted.org/packages/13/a3/a812df4e2dd5696d1f351d58b8fe16a405b234ad2886a0dab9183fb78109/pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc", size = 117552, upload-time = "2024-03-30T13:22:20.476Z" }, ] [[package]] name = "pygments" version = "2.19.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581 } +sdist = { url = "https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size = 4968581, upload-time = "2025-01-06T17:26:30.443Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293 }, + { url = "https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size = 1225293, upload-time = "2025-01-06T17:26:25.553Z" }, ] [[package]] @@ -334,9 +342,9 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "six" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432 } +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 }, + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, ] [[package]] @@ -344,9 +352,9 @@ name = "pywin32" version = "309" source = { registry = "https://pypi.org/simple" } wheels = [ - { url = "https://files.pythonhosted.org/packages/6c/c3/51aca6887cc5e410aa4cdc55662cf8438212440c67335c3f141b02eb8d52/pywin32-309-cp313-cp313-win32.whl", hash = "sha256:008bffd4afd6de8ca46c6486085414cc898263a21a63c7f860d54c9d02b45c8d", size = 8789700 }, - { url = "https://files.pythonhosted.org/packages/dd/66/330f265140fa814b4ed1bf16aea701f9d005f8f4ab57a54feb17f53afe7e/pywin32-309-cp313-cp313-win_amd64.whl", hash = "sha256:bd0724f58492db4cbfbeb1fcd606495205aa119370c0ddc4f70e5771a3ab768d", size = 9496714 }, - { url = "https://files.pythonhosted.org/packages/2c/84/9a51e6949a03f25cd329ece54dbf0846d57fadd2e79046c3b8d140aaa132/pywin32-309-cp313-cp313-win_arm64.whl", hash = "sha256:8fd9669cfd41863b688a1bc9b1d4d2d76fd4ba2128be50a70b0ea66b8d37953b", size = 8453052 }, + { url = "https://files.pythonhosted.org/packages/6c/c3/51aca6887cc5e410aa4cdc55662cf8438212440c67335c3f141b02eb8d52/pywin32-309-cp313-cp313-win32.whl", hash = "sha256:008bffd4afd6de8ca46c6486085414cc898263a21a63c7f860d54c9d02b45c8d", size = 8789700, upload-time = "2025-03-09T18:04:08.937Z" }, + { url = "https://files.pythonhosted.org/packages/dd/66/330f265140fa814b4ed1bf16aea701f9d005f8f4ab57a54feb17f53afe7e/pywin32-309-cp313-cp313-win_amd64.whl", hash = "sha256:bd0724f58492db4cbfbeb1fcd606495205aa119370c0ddc4f70e5771a3ab768d", size = 9496714, upload-time = "2025-03-09T18:04:10.619Z" }, + { url = "https://files.pythonhosted.org/packages/2c/84/9a51e6949a03f25cd329ece54dbf0846d57fadd2e79046c3b8d140aaa132/pywin32-309-cp313-cp313-win_arm64.whl", hash = "sha256:8fd9669cfd41863b688a1bc9b1d4d2d76fd4ba2128be50a70b0ea66b8d37953b", size = 8453052, upload-time = "2025-03-09T18:04:12.812Z" }, ] [[package]] @@ -356,38 +364,38 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cffi", marker = "implementation_name == 'pypy'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5a/e3/8d0382cb59feb111c252b54e8728257416a38ffcb2243c4e4775a3c990fe/pyzmq-26.2.1.tar.gz", hash = "sha256:17d72a74e5e9ff3829deb72897a175333d3ef5b5413948cae3cf7ebf0b02ecca", size = 278433 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/4f/2e/fa7a91ce349975971d6aa925b4c7e1a05abaae99b97ade5ace758160c43d/pyzmq-26.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:099b56ef464bc355b14381f13355542e452619abb4c1e57a534b15a106bf8e23", size = 942331 }, - { url = "https://files.pythonhosted.org/packages/64/2b/1f10b34b6dc7ff4b40f668ea25ba9b8093ce61d874c784b90229b367707b/pyzmq-26.2.1-cp313-cp313-macosx_10_15_universal2.whl", hash = "sha256:651726f37fcbce9f8dd2a6dab0f024807929780621890a4dc0c75432636871be", size = 1345831 }, - { url = "https://files.pythonhosted.org/packages/4c/8d/34884cbd4a8ec050841b5fb58d37af136766a9f95b0b2634c2971deb09da/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57dd4d91b38fa4348e237a9388b4423b24ce9c1695bbd4ba5a3eada491e09399", size = 670773 }, - { url = "https://files.pythonhosted.org/packages/0f/f4/d4becfcf9e416ad2564f18a6653f7c6aa917da08df5c3760edb0baa1c863/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d51a7bfe01a48e1064131f3416a5439872c533d756396be2b39e3977b41430f9", size = 908836 }, - { url = "https://files.pythonhosted.org/packages/07/fa/ab105f1b86b85cb2e821239f1d0900fccd66192a91d97ee04661b5436b4d/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7154d228502e18f30f150b7ce94f0789d6b689f75261b623f0fdc1eec642aab", size = 865369 }, - { url = "https://files.pythonhosted.org/packages/c9/48/15d5f415504572dd4b92b52db5de7a5befc76bb75340ba9f36f71306a66d/pyzmq-26.2.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:f1f31661a80cc46aba381bed475a9135b213ba23ca7ff6797251af31510920ce", size = 865676 }, - { url = "https://files.pythonhosted.org/packages/7e/35/2d91bcc7ccbb56043dd4d2c1763f24a8de5f05e06a134f767a7fb38e149c/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:290c96f479504439b6129a94cefd67a174b68ace8a8e3f551b2239a64cfa131a", size = 1201457 }, - { url = "https://files.pythonhosted.org/packages/6d/bb/aa7c5119307a5762b8dca6c9db73e3ab4bccf32b15d7c4f376271ff72b2b/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_i686.whl", hash = "sha256:f2c307fbe86e18ab3c885b7e01de942145f539165c3360e2af0f094dd440acd9", size = 1513035 }, - { url = "https://files.pythonhosted.org/packages/4f/4c/527e6650c2fccec7750b783301329c8a8716d59423818afb67282304ce5a/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b314268e716487bfb86fcd6f84ebbe3e5bec5fac75fdf42bc7d90fdb33f618ad", size = 1411881 }, - { url = "https://files.pythonhosted.org/packages/89/9f/e4412ea1b3e220acc21777a5edba8885856403d29c6999aaf00a9459eb03/pyzmq-26.2.1-cp313-cp313-win32.whl", hash = "sha256:edb550616f567cd5603b53bb52a5f842c0171b78852e6fc7e392b02c2a1504bb", size = 581354 }, - { url = "https://files.pythonhosted.org/packages/55/cd/f89dd3e9fc2da0d1619a82c4afb600c86b52bc72d7584953d460bc8d5027/pyzmq-26.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:100a826a029c8ef3d77a1d4c97cbd6e867057b5806a7276f2bac1179f893d3bf", size = 643560 }, - { url = "https://files.pythonhosted.org/packages/a7/99/5de4f8912860013f1116f818a0047659bc20d71d1bc1d48f874bdc2d7b9c/pyzmq-26.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:6991ee6c43e0480deb1b45d0c7c2bac124a6540cba7db4c36345e8e092da47ce", size = 558037 }, - { url = "https://files.pythonhosted.org/packages/06/0b/63b6d7a2f07a77dbc9768c6302ae2d7518bed0c6cee515669ca0d8ec743e/pyzmq-26.2.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:25e720dba5b3a3bb2ad0ad5d33440babd1b03438a7a5220511d0c8fa677e102e", size = 938580 }, - { url = "https://files.pythonhosted.org/packages/85/38/e5e2c3ffa23ea5f95f1c904014385a55902a11a67cd43c10edf61a653467/pyzmq-26.2.1-cp313-cp313t-macosx_10_15_universal2.whl", hash = "sha256:9ec6abfb701437142ce9544bd6a236addaf803a32628d2260eb3dbd9a60e2891", size = 1339670 }, - { url = "https://files.pythonhosted.org/packages/d2/87/da5519ed7f8b31e4beee8f57311ec02926822fe23a95120877354cd80144/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e1eb9d2bfdf5b4e21165b553a81b2c3bd5be06eeddcc4e08e9692156d21f1f6", size = 660983 }, - { url = "https://files.pythonhosted.org/packages/f6/e8/1ca6a2d59562e04d326a026c9e3f791a6f1a276ebde29da478843a566fdb/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:90dc731d8e3e91bcd456aa7407d2eba7ac6f7860e89f3766baabb521f2c1de4a", size = 896509 }, - { url = "https://files.pythonhosted.org/packages/5c/e5/0b4688f7c74bea7e4f1e920da973fcd7d20175f4f1181cb9b692429c6bb9/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b6a93d684278ad865fc0b9e89fe33f6ea72d36da0e842143891278ff7fd89c3", size = 853196 }, - { url = "https://files.pythonhosted.org/packages/8f/35/c17241da01195001828319e98517683dad0ac4df6fcba68763d61b630390/pyzmq-26.2.1-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:c1bb37849e2294d519117dd99b613c5177934e5c04a5bb05dd573fa42026567e", size = 855133 }, - { url = "https://files.pythonhosted.org/packages/d2/14/268ee49bbecc3f72e225addeac7f0e2bd5808747b78c7bf7f87ed9f9d5a8/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:632a09c6d8af17b678d84df442e9c3ad8e4949c109e48a72f805b22506c4afa7", size = 1191612 }, - { url = "https://files.pythonhosted.org/packages/5e/02/6394498620b1b4349b95c534f3ebc3aef95f39afbdced5ed7ee315c49c14/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_i686.whl", hash = "sha256:fc409c18884eaf9ddde516d53af4f2db64a8bc7d81b1a0c274b8aa4e929958e8", size = 1500824 }, - { url = "https://files.pythonhosted.org/packages/17/fc/b79f0b72891cbb9917698add0fede71dfb64e83fa3481a02ed0e78c34be7/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:17f88622b848805d3f6427ce1ad5a2aa3cf61f12a97e684dab2979802024d460", size = 1399943 }, +sdist = { url = "https://files.pythonhosted.org/packages/5a/e3/8d0382cb59feb111c252b54e8728257416a38ffcb2243c4e4775a3c990fe/pyzmq-26.2.1.tar.gz", hash = "sha256:17d72a74e5e9ff3829deb72897a175333d3ef5b5413948cae3cf7ebf0b02ecca", size = 278433, upload-time = "2025-01-30T11:42:00.757Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/2e/fa7a91ce349975971d6aa925b4c7e1a05abaae99b97ade5ace758160c43d/pyzmq-26.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:099b56ef464bc355b14381f13355542e452619abb4c1e57a534b15a106bf8e23", size = 942331, upload-time = "2025-01-30T11:39:10.936Z" }, + { url = "https://files.pythonhosted.org/packages/64/2b/1f10b34b6dc7ff4b40f668ea25ba9b8093ce61d874c784b90229b367707b/pyzmq-26.2.1-cp313-cp313-macosx_10_15_universal2.whl", hash = "sha256:651726f37fcbce9f8dd2a6dab0f024807929780621890a4dc0c75432636871be", size = 1345831, upload-time = "2025-01-30T11:39:14.136Z" }, + { url = "https://files.pythonhosted.org/packages/4c/8d/34884cbd4a8ec050841b5fb58d37af136766a9f95b0b2634c2971deb09da/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57dd4d91b38fa4348e237a9388b4423b24ce9c1695bbd4ba5a3eada491e09399", size = 670773, upload-time = "2025-01-30T11:39:16.881Z" }, + { url = "https://files.pythonhosted.org/packages/0f/f4/d4becfcf9e416ad2564f18a6653f7c6aa917da08df5c3760edb0baa1c863/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d51a7bfe01a48e1064131f3416a5439872c533d756396be2b39e3977b41430f9", size = 908836, upload-time = "2025-01-30T11:39:19.68Z" }, + { url = "https://files.pythonhosted.org/packages/07/fa/ab105f1b86b85cb2e821239f1d0900fccd66192a91d97ee04661b5436b4d/pyzmq-26.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7154d228502e18f30f150b7ce94f0789d6b689f75261b623f0fdc1eec642aab", size = 865369, upload-time = "2025-01-30T11:39:23.038Z" }, + { url = "https://files.pythonhosted.org/packages/c9/48/15d5f415504572dd4b92b52db5de7a5befc76bb75340ba9f36f71306a66d/pyzmq-26.2.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:f1f31661a80cc46aba381bed475a9135b213ba23ca7ff6797251af31510920ce", size = 865676, upload-time = "2025-01-30T11:39:25.173Z" }, + { url = "https://files.pythonhosted.org/packages/7e/35/2d91bcc7ccbb56043dd4d2c1763f24a8de5f05e06a134f767a7fb38e149c/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:290c96f479504439b6129a94cefd67a174b68ace8a8e3f551b2239a64cfa131a", size = 1201457, upload-time = "2025-01-30T11:39:27.022Z" }, + { url = "https://files.pythonhosted.org/packages/6d/bb/aa7c5119307a5762b8dca6c9db73e3ab4bccf32b15d7c4f376271ff72b2b/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_i686.whl", hash = "sha256:f2c307fbe86e18ab3c885b7e01de942145f539165c3360e2af0f094dd440acd9", size = 1513035, upload-time = "2025-01-30T11:39:29.756Z" }, + { url = "https://files.pythonhosted.org/packages/4f/4c/527e6650c2fccec7750b783301329c8a8716d59423818afb67282304ce5a/pyzmq-26.2.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:b314268e716487bfb86fcd6f84ebbe3e5bec5fac75fdf42bc7d90fdb33f618ad", size = 1411881, upload-time = "2025-01-30T11:39:32.631Z" }, + { url = "https://files.pythonhosted.org/packages/89/9f/e4412ea1b3e220acc21777a5edba8885856403d29c6999aaf00a9459eb03/pyzmq-26.2.1-cp313-cp313-win32.whl", hash = "sha256:edb550616f567cd5603b53bb52a5f842c0171b78852e6fc7e392b02c2a1504bb", size = 581354, upload-time = "2025-01-30T11:39:34.568Z" }, + { url = "https://files.pythonhosted.org/packages/55/cd/f89dd3e9fc2da0d1619a82c4afb600c86b52bc72d7584953d460bc8d5027/pyzmq-26.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:100a826a029c8ef3d77a1d4c97cbd6e867057b5806a7276f2bac1179f893d3bf", size = 643560, upload-time = "2025-01-30T11:39:36.905Z" }, + { url = "https://files.pythonhosted.org/packages/a7/99/5de4f8912860013f1116f818a0047659bc20d71d1bc1d48f874bdc2d7b9c/pyzmq-26.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:6991ee6c43e0480deb1b45d0c7c2bac124a6540cba7db4c36345e8e092da47ce", size = 558037, upload-time = "2025-01-30T11:39:38.753Z" }, + { url = "https://files.pythonhosted.org/packages/06/0b/63b6d7a2f07a77dbc9768c6302ae2d7518bed0c6cee515669ca0d8ec743e/pyzmq-26.2.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:25e720dba5b3a3bb2ad0ad5d33440babd1b03438a7a5220511d0c8fa677e102e", size = 938580, upload-time = "2025-01-30T11:39:40.536Z" }, + { url = "https://files.pythonhosted.org/packages/85/38/e5e2c3ffa23ea5f95f1c904014385a55902a11a67cd43c10edf61a653467/pyzmq-26.2.1-cp313-cp313t-macosx_10_15_universal2.whl", hash = "sha256:9ec6abfb701437142ce9544bd6a236addaf803a32628d2260eb3dbd9a60e2891", size = 1339670, upload-time = "2025-01-30T11:39:42.492Z" }, + { url = "https://files.pythonhosted.org/packages/d2/87/da5519ed7f8b31e4beee8f57311ec02926822fe23a95120877354cd80144/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e1eb9d2bfdf5b4e21165b553a81b2c3bd5be06eeddcc4e08e9692156d21f1f6", size = 660983, upload-time = "2025-01-30T11:39:44.503Z" }, + { url = "https://files.pythonhosted.org/packages/f6/e8/1ca6a2d59562e04d326a026c9e3f791a6f1a276ebde29da478843a566fdb/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:90dc731d8e3e91bcd456aa7407d2eba7ac6f7860e89f3766baabb521f2c1de4a", size = 896509, upload-time = "2025-01-30T11:39:46.388Z" }, + { url = "https://files.pythonhosted.org/packages/5c/e5/0b4688f7c74bea7e4f1e920da973fcd7d20175f4f1181cb9b692429c6bb9/pyzmq-26.2.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b6a93d684278ad865fc0b9e89fe33f6ea72d36da0e842143891278ff7fd89c3", size = 853196, upload-time = "2025-01-30T11:39:48.192Z" }, + { url = "https://files.pythonhosted.org/packages/8f/35/c17241da01195001828319e98517683dad0ac4df6fcba68763d61b630390/pyzmq-26.2.1-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:c1bb37849e2294d519117dd99b613c5177934e5c04a5bb05dd573fa42026567e", size = 855133, upload-time = "2025-01-30T11:39:50.097Z" }, + { url = "https://files.pythonhosted.org/packages/d2/14/268ee49bbecc3f72e225addeac7f0e2bd5808747b78c7bf7f87ed9f9d5a8/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:632a09c6d8af17b678d84df442e9c3ad8e4949c109e48a72f805b22506c4afa7", size = 1191612, upload-time = "2025-01-30T11:39:52.05Z" }, + { url = "https://files.pythonhosted.org/packages/5e/02/6394498620b1b4349b95c534f3ebc3aef95f39afbdced5ed7ee315c49c14/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_i686.whl", hash = "sha256:fc409c18884eaf9ddde516d53af4f2db64a8bc7d81b1a0c274b8aa4e929958e8", size = 1500824, upload-time = "2025-01-30T11:39:54.148Z" }, + { url = "https://files.pythonhosted.org/packages/17/fc/b79f0b72891cbb9917698add0fede71dfb64e83fa3481a02ed0e78c34be7/pyzmq-26.2.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:17f88622b848805d3f6427ce1ad5a2aa3cf61f12a97e684dab2979802024d460", size = 1399943, upload-time = "2025-01-30T11:39:58.293Z" }, ] [[package]] name = "six" version = "1.17.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031 } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050 }, + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] [[package]] @@ -399,43 +407,43 @@ dependencies = [ { name = "executing" }, { name = "pure-eval" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707 } +sdist = { url = "https://files.pythonhosted.org/packages/28/e3/55dcc2cfbc3ca9c29519eb6884dd1415ecb53b0e934862d3559ddcb7e20b/stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9", size = 44707, upload-time = "2023-09-30T13:58:05.479Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521 }, + { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521, upload-time = "2023-09-30T13:58:03.53Z" }, ] [[package]] name = "tornado" version = "6.4.2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/59/45/a0daf161f7d6f36c3ea5fc0c2de619746cc3dd4c76402e9db545bd920f63/tornado-6.4.2.tar.gz", hash = "sha256:92bad5b4746e9879fd7bf1eb21dce4e3fc5128d71601f80005afa39237ad620b", size = 501135 } +sdist = { url = "https://files.pythonhosted.org/packages/59/45/a0daf161f7d6f36c3ea5fc0c2de619746cc3dd4c76402e9db545bd920f63/tornado-6.4.2.tar.gz", hash = "sha256:92bad5b4746e9879fd7bf1eb21dce4e3fc5128d71601f80005afa39237ad620b", size = 501135, upload-time = "2024-11-22T03:06:38.036Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/26/7e/71f604d8cea1b58f82ba3590290b66da1e72d840aeb37e0d5f7291bd30db/tornado-6.4.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e828cce1123e9e44ae2a50a9de3055497ab1d0aeb440c5ac23064d9e44880da1", size = 436299 }, - { url = "https://files.pythonhosted.org/packages/96/44/87543a3b99016d0bf54fdaab30d24bf0af2e848f1d13d34a3a5380aabe16/tornado-6.4.2-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:072ce12ada169c5b00b7d92a99ba089447ccc993ea2143c9ede887e0937aa803", size = 434253 }, - { url = "https://files.pythonhosted.org/packages/cb/fb/fdf679b4ce51bcb7210801ef4f11fdac96e9885daa402861751353beea6e/tornado-6.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a017d239bd1bb0919f72af256a970624241f070496635784d9bf0db640d3fec", size = 437602 }, - { url = "https://files.pythonhosted.org/packages/4f/3b/e31aeffffc22b475a64dbeb273026a21b5b566f74dee48742817626c47dc/tornado-6.4.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c36e62ce8f63409301537222faffcef7dfc5284f27eec227389f2ad11b09d946", size = 436972 }, - { url = "https://files.pythonhosted.org/packages/22/55/b78a464de78051a30599ceb6983b01d8f732e6f69bf37b4ed07f642ac0fc/tornado-6.4.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bca9eb02196e789c9cb5c3c7c0f04fb447dc2adffd95265b2c7223a8a615ccbf", size = 437173 }, - { url = "https://files.pythonhosted.org/packages/79/5e/be4fb0d1684eb822c9a62fb18a3e44a06188f78aa466b2ad991d2ee31104/tornado-6.4.2-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:304463bd0772442ff4d0f5149c6f1c2135a1fae045adf070821c6cdc76980634", size = 437892 }, - { url = "https://files.pythonhosted.org/packages/f5/33/4f91fdd94ea36e1d796147003b490fe60a0215ac5737b6f9c65e160d4fe0/tornado-6.4.2-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:c82c46813ba483a385ab2a99caeaedf92585a1f90defb5693351fa7e4ea0bf73", size = 437334 }, - { url = "https://files.pythonhosted.org/packages/2b/ae/c1b22d4524b0e10da2f29a176fb2890386f7bd1f63aacf186444873a88a0/tornado-6.4.2-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:932d195ca9015956fa502c6b56af9eb06106140d844a335590c1ec7f5277d10c", size = 437261 }, - { url = "https://files.pythonhosted.org/packages/b5/25/36dbd49ab6d179bcfc4c6c093a51795a4f3bed380543a8242ac3517a1751/tornado-6.4.2-cp38-abi3-win32.whl", hash = "sha256:2876cef82e6c5978fde1e0d5b1f919d756968d5b4282418f3146b79b58556482", size = 438463 }, - { url = "https://files.pythonhosted.org/packages/61/cc/58b1adeb1bb46228442081e746fcdbc4540905c87e8add7c277540934edb/tornado-6.4.2-cp38-abi3-win_amd64.whl", hash = "sha256:908b71bf3ff37d81073356a5fadcc660eb10c1476ee6e2725588626ce7e5ca38", size = 438907 }, + { url = "https://files.pythonhosted.org/packages/26/7e/71f604d8cea1b58f82ba3590290b66da1e72d840aeb37e0d5f7291bd30db/tornado-6.4.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e828cce1123e9e44ae2a50a9de3055497ab1d0aeb440c5ac23064d9e44880da1", size = 436299, upload-time = "2024-11-22T03:06:20.162Z" }, + { url = "https://files.pythonhosted.org/packages/96/44/87543a3b99016d0bf54fdaab30d24bf0af2e848f1d13d34a3a5380aabe16/tornado-6.4.2-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:072ce12ada169c5b00b7d92a99ba089447ccc993ea2143c9ede887e0937aa803", size = 434253, upload-time = "2024-11-22T03:06:22.39Z" }, + { url = "https://files.pythonhosted.org/packages/cb/fb/fdf679b4ce51bcb7210801ef4f11fdac96e9885daa402861751353beea6e/tornado-6.4.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a017d239bd1bb0919f72af256a970624241f070496635784d9bf0db640d3fec", size = 437602, upload-time = "2024-11-22T03:06:24.214Z" }, + { url = "https://files.pythonhosted.org/packages/4f/3b/e31aeffffc22b475a64dbeb273026a21b5b566f74dee48742817626c47dc/tornado-6.4.2-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c36e62ce8f63409301537222faffcef7dfc5284f27eec227389f2ad11b09d946", size = 436972, upload-time = "2024-11-22T03:06:25.559Z" }, + { url = "https://files.pythonhosted.org/packages/22/55/b78a464de78051a30599ceb6983b01d8f732e6f69bf37b4ed07f642ac0fc/tornado-6.4.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bca9eb02196e789c9cb5c3c7c0f04fb447dc2adffd95265b2c7223a8a615ccbf", size = 437173, upload-time = "2024-11-22T03:06:27.584Z" }, + { url = "https://files.pythonhosted.org/packages/79/5e/be4fb0d1684eb822c9a62fb18a3e44a06188f78aa466b2ad991d2ee31104/tornado-6.4.2-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:304463bd0772442ff4d0f5149c6f1c2135a1fae045adf070821c6cdc76980634", size = 437892, upload-time = "2024-11-22T03:06:28.933Z" }, + { url = "https://files.pythonhosted.org/packages/f5/33/4f91fdd94ea36e1d796147003b490fe60a0215ac5737b6f9c65e160d4fe0/tornado-6.4.2-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:c82c46813ba483a385ab2a99caeaedf92585a1f90defb5693351fa7e4ea0bf73", size = 437334, upload-time = "2024-11-22T03:06:30.428Z" }, + { url = "https://files.pythonhosted.org/packages/2b/ae/c1b22d4524b0e10da2f29a176fb2890386f7bd1f63aacf186444873a88a0/tornado-6.4.2-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:932d195ca9015956fa502c6b56af9eb06106140d844a335590c1ec7f5277d10c", size = 437261, upload-time = "2024-11-22T03:06:32.458Z" }, + { url = "https://files.pythonhosted.org/packages/b5/25/36dbd49ab6d179bcfc4c6c093a51795a4f3bed380543a8242ac3517a1751/tornado-6.4.2-cp38-abi3-win32.whl", hash = "sha256:2876cef82e6c5978fde1e0d5b1f919d756968d5b4282418f3146b79b58556482", size = 438463, upload-time = "2024-11-22T03:06:34.71Z" }, + { url = "https://files.pythonhosted.org/packages/61/cc/58b1adeb1bb46228442081e746fcdbc4540905c87e8add7c277540934edb/tornado-6.4.2-cp38-abi3-win_amd64.whl", hash = "sha256:908b71bf3ff37d81073356a5fadcc660eb10c1476ee6e2725588626ce7e5ca38", size = 438907, upload-time = "2024-11-22T03:06:36.71Z" }, ] [[package]] name = "traitlets" version = "5.14.3" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/eb/79/72064e6a701c2183016abbbfedaba506d81e30e232a68c9f0d6f6fcd1574/traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7", size = 161621 } +sdist = { url = "https://files.pythonhosted.org/packages/eb/79/72064e6a701c2183016abbbfedaba506d81e30e232a68c9f0d6f6fcd1574/traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7", size = 161621, upload-time = "2024-04-19T11:11:49.746Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size = 85359 }, + { url = "https://files.pythonhosted.org/packages/00/c0/8f5d070730d7836adc9c9b6408dec68c6ced86b304a9b26a14df072a6e8c/traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f", size = 85359, upload-time = "2024-04-19T11:11:46.763Z" }, ] [[package]] name = "wcwidth" version = "0.2.13" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/6c/63/53559446a878410fc5a5974feb13d31d78d752eb18aeba59c7fef1af7598/wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5", size = 101301 } +sdist = { url = "https://files.pythonhosted.org/packages/6c/63/53559446a878410fc5a5974feb13d31d78d752eb18aeba59c7fef1af7598/wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5", size = 101301, upload-time = "2024-01-06T02:10:57.829Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859", size = 34166 }, + { url = "https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859", size = 34166, upload-time = "2024-01-06T02:10:55.763Z" }, ]