From 689a9c117c6a535a5c48e1f6368ea652c16c6c7b Mon Sep 17 00:00:00 2001 From: Ever77x Date: Fri, 1 Oct 2021 23:50:24 -0500 Subject: [PATCH 01/13] ading git-fu.py file with original message --- module-1/lab-resolving-git-conflicts/git-fu.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 module-1/lab-resolving-git-conflicts/git-fu.py diff --git a/module-1/lab-resolving-git-conflicts/git-fu.py b/module-1/lab-resolving-git-conflicts/git-fu.py new file mode 100644 index 000000000..e69de29bb From 1681abecc7b50b8d885f741ddfb8f56adc99bc77 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 00:00:19 -0500 Subject: [PATCH 02/13] adding git-fu.txt --- module-1/lab-resolving-git-conflicts/git-fu.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 module-1/lab-resolving-git-conflicts/git-fu.py diff --git a/module-1/lab-resolving-git-conflicts/git-fu.py b/module-1/lab-resolving-git-conflicts/git-fu.py deleted file mode 100644 index e69de29bb..000000000 From 5f74b57337f65bc6391c97519e4bd9e36631f791 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 00:02:13 -0500 Subject: [PATCH 03/13] adding altering file git-fu --- module-1/lab-resolving-git-conflicts/git-fu.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 module-1/lab-resolving-git-conflicts/git-fu.py diff --git a/module-1/lab-resolving-git-conflicts/git-fu.py b/module-1/lab-resolving-git-conflicts/git-fu.py deleted file mode 100644 index e69de29bb..000000000 From 5ef0b4e7d05b99b5f95348de45173f9a7f79021f Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 00:09:43 -0500 Subject: [PATCH 04/13] archivo bueno --- module-1/lab-resolving-git-conflicts/ejemplo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 module-1/lab-resolving-git-conflicts/ejemplo.txt diff --git a/module-1/lab-resolving-git-conflicts/ejemplo.txt b/module-1/lab-resolving-git-conflicts/ejemplo.txt new file mode 100644 index 000000000..a5336f0cd --- /dev/null +++ b/module-1/lab-resolving-git-conflicts/ejemplo.txt @@ -0,0 +1 @@ +Archivo bueno \ No newline at end of file From b961bf771d6e60e519612513c71d66f0c0af3bf1 Mon Sep 17 00:00:00 2001 From: Everardo Guerrero <89491440+Ever77x@users.noreply.github.com> Date: Sat, 2 Oct 2021 00:28:47 -0500 Subject: [PATCH 05/13] Delete ejemplo.txt --- module-1/lab-resolving-git-conflicts/ejemplo.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 module-1/lab-resolving-git-conflicts/ejemplo.txt diff --git a/module-1/lab-resolving-git-conflicts/ejemplo.txt b/module-1/lab-resolving-git-conflicts/ejemplo.txt deleted file mode 100644 index a5336f0cd..000000000 --- a/module-1/lab-resolving-git-conflicts/ejemplo.txt +++ /dev/null @@ -1 +0,0 @@ -Archivo bueno \ No newline at end of file From b9e4c257d46b0aeaad858c417c82773567568958 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 00:54:17 -0500 Subject: [PATCH 06/13] =?UTF-8?q?a=C3=B1adiendo=20archivo=20alterardo=20ab?= =?UTF-8?q?out-me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module-1/lab-resolving-git-conflicts/your-code/about-me.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md index 30a999d50..ed3883e5e 100644 --- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md +++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md @@ -1,4 +1,4 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque viverra laoreet lorem et dapibus. Integer auctor dignissim egestas. Ut id purus neque. Pellentesque imperdiet lacus in libero laoreet, at tempus felis tristique. Cras fermentum erat a dui vulputate gravida. Nulla aliquet nisi interdum nulla pretium, ac vestibulum diam congue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus lacus risus, sodales vitae viverra quis, maximus ac ipsum. Sed consequat viverra mattis. Curabitur iaculis varius mollis. +ZZZZ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque viverra laoreet lorem et dapibus. Integer auctor dignissim egestas. Ut id purus neque. Pellentesque imperdiet lacus in libero laoreet, at tempus felis tristique. Cras fermentum erat a dui vulputate gravida. Nulla aliquet nisi interdum nulla pretium, ac vestibulum diam congue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus lacus risus, sodales vitae viverra quis, maximus ac ipsum. Sed consequat viverra mattis. Curabitur iaculis varius mollis. Ut porttitor iaculis tellus bibendum euismod. Morbi porta, ante nec tempus porta, felis mi faucibus lacus, sed tristique purus nunc sed est. Aenean pulvinar urna ut lacus interdum aliquam. Pellentesque sit amet magna accumsan, sagittis metus a, volutpat velit. Mauris vitae ex vehicula, posuere nisi sed, sagittis nunc. Ut scelerisque, mi non tristique tristique, mi enim luctus nunc, eu mattis sem quam auctor nunc. Donec lobortis tellus eget blandit ultricies. Vivamus euismod metus eget leo blandit, at malesuada magna efficitur. Praesent sodales faucibus mi, ullamcorper ultrices orci. Vivamus maximus malesuada massa, nec placerat leo feugiat vel. Nam vitae eleifend enim. Nullam interdum ipsum velit, vitae faucibus lectus blandit euismod. From 97f294738aab5236d1498cf9839b2c5a37e2e803 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 01:22:17 -0500 Subject: [PATCH 07/13] =?UTF-8?q?a=C3=B1adiendo=20archivo=20about-me=20mod?= =?UTF-8?q?ificado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../your-code/about-me.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md index 30a999d50..e2e5897b1 100644 --- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md +++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md @@ -1,7 +1,16 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque viverra laoreet lorem et dapibus. Integer auctor dignissim egestas. Ut id purus neque. Pellentesque imperdiet lacus in libero laoreet, at tempus felis tristique. Cras fermentum erat a dui vulputate gravida. Nulla aliquet nisi interdum nulla pretium, ac vestibulum diam congue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus lacus risus, sodales vitae viverra quis, maximus ac ipsum. Sed consequat viverra mattis. Curabitur iaculis varius mollis. +# Who am I -Ut porttitor iaculis tellus bibendum euismod. Morbi porta, ante nec tempus porta, felis mi faucibus lacus, sed tristique purus nunc sed est. Aenean pulvinar urna ut lacus interdum aliquam. Pellentesque sit amet magna accumsan, sagittis metus a, volutpat velit. Mauris vitae ex vehicula, posuere nisi sed, sagittis nunc. Ut scelerisque, mi non tristique tristique, mi enim luctus nunc, eu mattis sem quam auctor nunc. Donec lobortis tellus eget blandit ultricies. Vivamus euismod metus eget leo blandit, at malesuada magna efficitur. Praesent sodales faucibus mi, ullamcorper ultrices orci. Vivamus maximus malesuada massa, nec placerat leo feugiat vel. Nam vitae eleifend enim. Nullam interdum ipsum velit, vitae faucibus lectus blandit euismod. +* Soy de CDMX +* Trabajo en Telefonica Movistar +* Tnego un poco de experiencia con SQL -Suspendisse ut malesuada ex. Nulla ultricies nisl et nisi rhoncus sollicitudin. Vestibulum maximus iaculis ligula, nec commodo nunc ullamcorper nec. Duis quis condimentum sapien. Cras vestibulum interdum felis eu auctor. Quisque semper, magna at dapibus faucibus, felis risus semper ligula, id aliquam lectus ligula vel nisi. In hac habitasse platea dictumst. Donec arcu sapien, suscipit ac dictum et, imperdiet id tortor. Maecenas ornare sodales interdum. Mauris dictum felis eu eros vestibulum cursus. Phasellus accumsan, turpis ut malesuada sollicitudin, augue leo venenatis ante, vel convallis tellus diam sit amet lacus. Aenean eu mauris eros. Praesent ante lacus, gravida sit amet tellus nec, laoreet ultrices lacus. Integer commodo semper vestibulum. Fusce felis massa, consectetur facilisis rutrum nec, pulvinar et nisi. +# Why am I here -Morbi fermentum ultricies tortor, vehicula ultrices eros elementum a. Duis ornare aliquam facilisis. Proin aliquam tincidunt odio vitae dignissim. Sed malesuada lacinia massa, nec blandit urna auctor elementum. Duis auctor non tortor in consequat. Mauris id vestibulum risus. In eget erat sed lacus efficitur viverra sed eu est. Aliquam interdum consequat molestie. Aliquam metus nisi, blandit non semper ut, blandit vel leo. Cras dictum turpis erat, sed iaculis ligula facilisis dapibus. Aliquam posuere dignissim fermentum. Praesent at neque sit amet lectus ornare iaculis. Curabitur id urna quis lorem varius ultrices eu sit amet sapien. Curabitur maximus volutpat suscipit. Proin imperdiet elementum lacus a eleifend. Sed tempor lacus posuere diam vehicula iaculis. +* El querer aprender de programación para realizar analisis de data +* Analisis, programación y generación de insights + +# What will I do after the bootcamp? + +* Fintech, Consumo Masivo y empresas de Tecnlogia (Google, Amazon, Facebook) +* Estrategia de negocio a partir de analisis de data +* Que a partir de los ánalisis que genere se tomen decisiones clave para crecer el negocio en donde me encuentre From d9e53c24bf159de61100b2637e67e2a49731d6bf Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sat, 2 Oct 2021 01:42:54 -0500 Subject: [PATCH 08/13] =?UTF-8?q?a=C3=B1adiendo=20archivo=20con=20conflict?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module-1/lab-resolving-git-conflicts/your-code/about-me.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md index 188819795..68ac0f053 100644 --- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md +++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md @@ -1,4 +1,4 @@ - +ESTO ES LO QUE VOY A PONER EN MERGE - (NO HACER ESTO) # Who am I * Soy de CDMX From 13a553c0adeccc4ebbeffd58d686b157739de7d7 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sun, 3 Oct 2021 00:13:19 -0500 Subject: [PATCH 09/13] =?UTF-8?q?a=C3=B1adiendo=20about-me.nd=20de=20la=20?= =?UTF-8?q?rama=20secundaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module-1/lab-resolving-git-conflicts/your-code/about-me.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md index 68ac0f053..ae230f4ee 100644 --- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md +++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md @@ -1,4 +1,4 @@ -ESTO ES LO QUE VOY A PONER EN MERGE - (NO HACER ESTO) +ESTO ES CAMBIO EN LA BRANCH # Who am I * Soy de CDMX From bca0aa0b555f2a925458aeb4f8f31e538dfbaada Mon Sep 17 00:00:00 2001 From: Ever77x Date: Sun, 3 Oct 2021 00:14:59 -0500 Subject: [PATCH 10/13] =?UTF-8?q?a=C3=B1adiendo=20about-me.md=20de=20la=20?= =?UTF-8?q?rama=20master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module-1/lab-resolving-git-conflicts/your-code/about-me.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md index 68ac0f053..3fd17a52c 100644 --- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md +++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md @@ -1,4 +1,4 @@ -ESTO ES LO QUE VOY A PONER EN MERGE - (NO HACER ESTO) +esto es lo de la rama MASTER # Who am I * Soy de CDMX From 5f2b89f38513d2e45305ff4b73fb3aaa67dc09a2 Mon Sep 17 00:00:00 2001 From: Everardo Guerrero <89491440+Ever77x@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:35:27 -0500 Subject: [PATCH 11/13] 20211003_EJGS_challenge 1 --- .../your-code/20211003_EJGS_challenge-1.ipynb | 436 ++++++++++++++++++ 1 file changed, 436 insertions(+) create mode 100644 module-1/lab-string-operations/your-code/20211003_EJGS_challenge-1.ipynb diff --git a/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-1.ipynb b/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-1.ipynb new file mode 100644 index 000000000..2f0f82192 --- /dev/null +++ b/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-1.ipynb @@ -0,0 +1,436 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# String Operations Lab\n", + "\n", + "**Before your start:**\n", + "\n", + "- Read the README.md file\n", + "- Comment as much as you can and use the resources in the README.md file\n", + "- Happy learning!" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [], + "source": [ + "import re" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Challenge 1 - Combining Strings\n", + "\n", + "Combining strings is an important skill to acquire. There are multiple ways of combining strings in Python, as well as combining strings with variables. We will explore this in the first challenge. In the cell below, combine the strings in the list and add spaces between the strings (do not add a space after the last string). Insert a period after the last string." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Durante un tiempo no estuvo segura de si su marido era su marido.\n" + ] + } + ], + "source": [ + "str_list = ['Durante', 'un', 'tiempo', 'no', 'estuvo', 'segura', 'de', 'si', 'su', 'marido', 'era', 'su', 'marido']\n", + "# Your code here:\n", + "\n", + "new_requirement = \" \".join(str_list) + \".\"\n", + "\n", + "print(new_requirement)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the cell below, use the list of strings to create a grocery list. Start the list with the string `Grocery list: ` and include a comma and a space between each item except for the last one. Include a period at the end. Only include foods in the list that start with the letter 'b' and ensure all foods are lower case." + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Grocery list:bananas, bread, brownie mix, broccoli.\n" + ] + } + ], + "source": [ + "food_list = ['Bananas', 'Chocolate', 'bread', 'diapers', 'Ice Cream', 'Brownie Mix', 'broccoli']\n", + "# Your code here:\n", + "\n", + "x = food_list[0]\n", + "y = food_list[2]\n", + "w = food_list[5]\n", + "z = food_list[6]\n", + "\n", + "grocery_list = x + \", \"+ y + \", \" + w + \", \" + z + \".\"\n", + "grocery_list_minusculas = grocery_list.lower()\n", + "answer= \"Grocery list:\" + grocery_list_minusculas\n", + "\n", + "print(answer)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the cell below, write a function that computes the area of a circle using its radius. Compute the area of the circle and insert the radius and the area between the two strings. Make sure to include spaces between the variable and the strings. \n", + "\n", + "Note: You can use the techniques we have learned so far or use f-strings. F-strings allow us to embed code inside strings. You can read more about f-strings [here](https://www.python.org/dev/peps/pep-0498/)." + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Valor de Pi 3.141592653589793\n", + "el área del ciruclo con radio 4.5 es 63.61725123519331\n", + "The area of the circle with radius: 4.5 is: 63.61725123519331\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "string1 = \"The area of the circle with radius:\"\n", + "string2 = \"is:\"\n", + "radius = 4.5\n", + "\n", + "##def area(x, pi = math.pi):\n", + " # This function takes a radius and returns the area of a circle. We also pass a default value for pi.\n", + " # Input: Float (and default value for pi)\n", + " # Output: Float\n", + " \n", + " # Sample input: 5.0\n", + " # Sample Output: 78.53981633\n", + " \n", + " # Your code here:\n", + " \n", + "pi = math.pi\n", + "print(\"Valor de Pi\", pi)\n", + "area = math.pi * (radius * radius)\n", + "print(\"el área del ciruclo con radio\", radius, \"es\", area)\n", + " \n", + "# Your output string here:\n", + "print(string1, radius, string2, area)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Challenge 2 - Splitting Strings\n", + "\n", + "We have first looked at combining strings into one long string. There are times where we need to do the opposite and split the string into smaller components for further analysis. \n", + "\n", + "In the cell below, split the string into a list of strings using the space delimiter. Count the frequency of each word in the string in a dictionary. Strip the periods, line breaks and commas from the text. Make sure to remove empty strings from your dictionary." + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Some say the world will end in fire Some say in ice From what I’ve tasted of desire I hold with those who favor fire But if it had to perish twice I think I know enough of hate To say that for destruction ice Is also great And would suffice\n", + "['Some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'Some', 'say', 'in', 'ice', 'From', 'what', 'I’ve', 'tasted', 'of', 'desire', 'I', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'But', 'if', 'it', 'had', 'to', 'perish', 'twice', 'I', 'think', 'I', 'know', 'enough', 'of', 'hate', 'To', 'say', 'that', 'for', 'destruction', 'ice', 'Is', 'also', 'great', 'And', 'would', 'suffice']\n", + "{'Some': 2, 'say': 3, 'the': 1, 'world': 1, 'will': 1, 'end': 1, 'in': 2, 'fire': 2, 'ice': 2, 'From': 1, 'what': 1, 'I’ve': 1, 'tasted': 1, 'of': 2, 'desire': 1, 'I': 3, 'hold': 1, 'with': 1, 'those': 1, 'who': 1, 'favor': 1, 'But': 1, 'if': 1, 'it': 1, 'had': 1, 'to': 1, 'perish': 1, 'twice': 1, 'think': 1, 'know': 1, 'enough': 1, 'hate': 1, 'To': 1, 'that': 1, 'for': 1, 'destruction': 1, 'Is': 1, 'also': 1, 'great': 1, 'And': 1, 'would': 1, 'suffice': 1}\n" + ] + } + ], + "source": [ + "poem = \"\"\"Some say the world will end in fire,\n", + "Some say in ice.\n", + "From what I’ve tasted of desire\n", + "I hold with those who favor fire.\n", + "But if it had to perish twice,\n", + "I think I know enough of hate\n", + "To say that for destruction ice\n", + "Is also great\n", + "And would suffice.\"\"\"\n", + "\n", + "# Your code here:\n", + "\n", + "poem2 = poem.replace(\"\\n\", \" \")\n", + "#print(poem2)\n", + "\n", + "poem3 = poem2.replace(\",\",\"\")\n", + "#print(poem3)\n", + "\n", + "poem4 = poem3.replace(\".\",\"\")\n", + "#print(poem4)\n", + "\n", + "##ANSWER 1: string sin saltos de lineas, puntos y comas\n", + "\n", + "answer = poem4\n", + "print(poem4)\n", + "\n", + "##ANSWER 2: CREAR LISTA - split \n", + "\n", + "answer_list = answer.split()\n", + "print(answer_list)\n", + "\n", + "##ANSWER3: CONTAR CADA ELEMENTO \n", + " ##realmente esto lo encontre en el repositorio de alguien mas y todavia no logro \"encontrar el racional de cómo esto funciona\" \n", + "\n", + "frequency = {}\n", + "for i in answer_list:\n", + " frequency[i] = frequency.setdefault(i, 0) + 1\n", + " \n", + "print(frequency)\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the cell below, find all the words that appear in the text and do not appear in the blacklist. You must parse the string but can choose any data structure you wish for the words that do not appear in the blacklist. Remove all non letter characters and convert all words to lower case." + ] + }, + { + "cell_type": "code", + "execution_count": 151, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'waterd', 'was', 'shine', 'smiles', 'grow', 'bore', 'apple', 'knew', 'that', 'deceitful', 'glad', 'into', 'morning', 'pole', 'an', 'the', 'did', 'and', 'veild', 'grew', 'tears', 'had', 'night', 'wrath', 'both', 'tree', 'sunned', 'foe', 'friend', 'day', 'mine', 'outstretched', 'angry', 'beheld', 'with', 'fears', 'end', 'see', 'in', 'he', 'it', 'stole', 'told', 'soft', 'bright', 'wiles', 'till', 'garden', 'my', 'not', 'beneath', 'when'}\n" + ] + } + ], + "source": [ + "blacklist = ['and', 'as', 'an', 'a', 'the', 'in', 'it']\n", + "\n", + "poem = \"\"\"I was angry with my friend; \n", + "I told my wrath, my wrath did end.\n", + "I was angry with my foe: \n", + "I told it not, my wrath did grow. \n", + "\n", + "And I waterd it in fears,\n", + "Night & morning with my tears: \n", + "And I sunned it with smiles,\n", + "And with soft deceitful wiles. \n", + "\n", + "And it grew both day and night. \n", + "Till it bore an apple bright. \n", + "And my foe beheld it shine,\n", + "And he knew that it was mine. \n", + "\n", + "And into my garden stole, \n", + "When the night had veild the pole; \n", + "In the morning glad I see; \n", + "My foe outstretched beneath the tree.\"\"\"\n", + "\n", + "# Your code here:\n", + "\n", + "poem2 = poem.replace(\"\\n\", \" \")\n", + "#print(poem2)\n", + "\n", + "poem3 = poem2.replace(\",\",\"\")\n", + "#print(poem3)\n", + "\n", + "poem4 = poem3.replace(\".\",\"\")\n", + "#print(poem4)\n", + "\n", + "poem5 = poem4.replace(\";\",\"\")\n", + "#print(poem5)\n", + "\n", + "poem6 = poem5.replace(\":\",\"\")\n", + "#print(poem6)\n", + "\n", + "poem7 = poem6.lower()\n", + "#print(poem7)\n", + "\n", + "list_poem = poem7.split()\n", + "#print(list_poem)\n", + "\n", + "\n", + "answer_set = set(list_poem).difference(set(poem))\n", + "print(answer_set)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Challenge 3 - Regular Expressions\n", + "\n", + "Sometimes, we would like to perform more complex manipulations of our string. This is where regular expressions come in handy. In the cell below, return all characters that are upper case from the string specified below." + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The apparition of these faces in the crowd Petals on a wet black bough\n", + "['T', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ', ' ', ' ']\n" + ] + } + ], + "source": [ + "poem = \"\"\"The apparition of these faces in the crowd;\n", + "Petals on a wet, black bough.\"\"\"\n", + "\n", + "# Your code here:\n", + "\n", + "import re \n", + "\n", + "poem2 = poem.replace(\"\\n\", \" \")\n", + "#print(poem2)\n", + "\n", + "poem3 = poem2.replace(\",\",\"\")\n", + "#print(poem3)\n", + "\n", + "poem4 = poem3.replace(\".\",\"\")\n", + "#print(poem4)\n", + "\n", + "poem5 = poem4.replace(\";\",\"\")\n", + "#print(poem5)\n", + "\n", + "poem6 = poem5.replace(\":\",\"\")\n", + "print(poem6)\n", + "\n", + "print(re.findall('[^a-z]', poem6))\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the cell below, filter the list provided and return all elements of the list containing a number. To filter the list, use the `re.search` function. Check if the function does not return `None`. You can read more about the `re.search` function [here](https://docs.python.org/3/library/re.html)." + ] + }, + { + "cell_type": "code", + "execution_count": 164, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['123abc', 'abc123', 'JohnSmith1', 'ABBY4', 'JANE']\n", + "None\n" + ] + } + ], + "source": [ + "data = ['123abc', 'abc123', 'JohnSmith1', 'ABBY4', 'JANE']\n", + "\n", + "# Your code here:\n", + "\n", + "import re \n", + "\n", + "string = str(data)\n", + "print(string)\n", + "\n", + "answer = re.search(\"\\number\",string)\n", + "print(answer)\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Bonus Challenge - Regular Expressions II\n", + "\n", + "In the cell below, filter the list provided to keep only strings containing at least one digit and at least one lower case letter. As in the previous question, use the `re.search` function and check that the result is not `None`.\n", + "\n", + "To read more about regular expressions, check out [this link](https://developers.google.com/edu/python/regular-expressions)." + ] + }, + { + "cell_type": "code", + "execution_count": 158, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 4)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m4\u001b[0m\n\u001b[0;31m re.search(in[0,1,2,3,4,5,6,7,8,9],data)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "data = ['123abc', 'abc123', 'JohnSmith1', 'ABBY4', 'JANE']\n", + "# Your code here:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 1809ec3d254f81028913d7c31393e07d24b18c27 Mon Sep 17 00:00:00 2001 From: Everardo Guerrero <89491440+Ever77x@users.noreply.github.com> Date: Mon, 4 Oct 2021 00:00:57 -0500 Subject: [PATCH 12/13] 20211003_EJGS_challenge-2. --- .../your-code/20211003_EJGS_challenge-2.ipynb | 431 ++++++++++++++++++ 1 file changed, 431 insertions(+) create mode 100644 module-1/lab-string-operations/your-code/20211003_EJGS_challenge-2.ipynb diff --git a/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-2.ipynb b/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-2.ipynb new file mode 100644 index 000000000..1c3fb1c57 --- /dev/null +++ b/module-1/lab-string-operations/your-code/20211003_EJGS_challenge-2.ipynb @@ -0,0 +1,431 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Bag of Words Lab\n", + "\n", + "## Introduction\n", + "\n", + "**Bag of words (BoW)** is an important technique in text mining and [information retrieval](https://en.wikipedia.org/wiki/Information_retrieval). BoW uses term-frequency vectors to represent the content of text documents which makes it possible to use mathematics and computer programs to analyze and compare text documents.\n", + "\n", + "BoW contains the following information:\n", + "\n", + "1. A dictionary of all the terms (words) in the text documents. The terms are normalized in terms of the letter case (e.g. `Ironhack` => `ironhack`), tense (e.g. `had` => `have`), singular form (e.g. `students` => `student`), etc.\n", + "1. The number of occurrences of each normalized term in each document.\n", + "\n", + "For example, assume we have three text documents:\n", + "\n", + "DOC 1: **Ironhack is cool.**\n", + "\n", + "DOC 2: **I love Ironhack.**\n", + "\n", + "DOC 3: **I am a student at Ironhack.**\n", + "\n", + "The BoW of the above documents looks like below:\n", + "\n", + "| TERM | DOC 1 | DOC 2 | Doc 3 |\n", + "|---|---|---|---|\n", + "| a | 0 | 0 | 1 |\n", + "| am | 0 | 0 | 1 |\n", + "| at | 0 | 0 | 1 |\n", + "| cool | 1 | 0 | 0 |\n", + "| i | 0 | 1 | 1 |\n", + "| ironhack | 1 | 1 | 1 |\n", + "| is | 1 | 0 | 0 |\n", + "| love | 0 | 1 | 0 |\n", + "| student | 0 | 0 | 1 |\n", + "\n", + "\n", + "The term-frequency array of each document in BoW can be considered a high-dimensional vector. Data scientists use these vectors to represent the content of the documents. For instance, DOC 1 is represented with `[0, 0, 0, 1, 0, 1, 1, 0, 0]`, DOC 2 is represented with `[0, 0, 0, 0, 1, 1, 0, 1, 0]`, and DOC 3 is represented with `[1, 1, 1, 0, 1, 1, 0, 0, 1]`. **Two documents are considered identical if their vector representations have close [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity).**\n", + "\n", + "In real practice there are many additional techniques to improve the text mining accuracy such as using [stop words](https://en.wikipedia.org/wiki/Stop_words) (i.e. neglecting common words such as `a`, `I`, `to` that don't contribute much meaning), synonym list (e.g. consider `New York City` the same as `NYC` and `Big Apple`), and HTML tag removal if the data sources are webpages. In Module 3 you will learn how to use those advanced techniques for [natural language processing](https://en.wikipedia.org/wiki/Natural_language_processing), a component of text mining.\n", + "\n", + "In real text mining projects data analysts use packages such as Scikit-Learn and NLTK, which you will learn in Module 3, to extract BoW from texts. In this exercise, however, we would like you to create BoW manually with Python. This is because by manually creating BoW you can better understand the concept and also practice the Python skills you have learned so far." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## The Challenge\n", + "\n", + "We need to create a BoW from a list of documents. The documents (`doc1.txt`, `doc2.txt`, and `doc3.txt`) can be found in the `your-code` directory of this exercise. You will read the content of each document into an array of strings named `corpus`.\n", + "\n", + "*What is a corpus (plural: corpora)? Read the reference in the README file.*\n", + "\n", + "Your challenge is to use Python to generate the BoW of these documents. Your BoW should look like below:\n", + "\n", + "```python\n", + "bag_of_words = ['a', 'am', 'at', 'cool', 'i', 'ironhack', 'is', 'love', 'student']\n", + "\n", + "term_freq = [\n", + " [0, 0, 0, 1, 0, 1, 1, 0, 0],\n", + " [0, 0, 0, 0, 1, 1, 0, 1, 0],\n", + " [1, 1, 1, 0, 1, 1, 0, 0, 1],\n", + "]\n", + "```\n", + "\n", + "Now let's define the `docs` array that contains the paths of `doc1.txt`, `doc2.txt`, and `doc3.txt`." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "docs = ['doc1.txt', 'doc2.txt', 'doc3.txt']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Define an empty array `corpus` that will contain the content strings of the docs. Loop `docs` and read the content of each doc into the `corpus` array." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ironhack is cool.\n", + "I love Ironhack.\n", + "I am a student at Ironhack.\n" + ] + } + ], + "source": [ + "corpus = []\n", + "\n", + "# Write your code here\n", + "\n", + "doc1 = open(\"doc1.txt\")\n", + "archivo1 = doc1.read()\n", + "print(archivo1)\n", + "\n", + "doc2 = open(\"doc2.txt\")\n", + "archivo2 = doc2.read()\n", + "print(archivo2)\n", + "\n", + "doc3 = open(\"doc3.txt\")\n", + "archivo3 = doc3.read()\n", + "print(archivo3)\n", + "\n", + "corpus.append(archivo1)\n", + "corpus.append(archivo2)\n", + "corpus.append(archivo3)\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Print `corpus`." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Ironhack is cool.', 'I love Ironhack.', 'I am a student at Ironhack.']\n" + ] + } + ], + "source": [ + "print(corpus)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You expected to see:\n", + "\n", + "```['ironhack is cool', 'i love ironhack', 'i am a student at ironhack']```\n", + "\n", + "But you actually saw:\n", + "\n", + "```['Ironhack is cool.', 'I love Ironhack.', 'I am a student at Ironhack.']```\n", + "\n", + "This is because you haven't done two important steps:\n", + "\n", + "1. Remove punctuation from the strings\n", + "\n", + "1. Convert strings to lowercase\n", + "\n", + "Write your code below to process `corpus` (convert to lower case and remove special characters)." + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Ironhack is cool.', 'I love Ironhack.', 'I am a student at Ironhack.']\n", + "['ironhack is cool', 'i love ironhack', 'i am a student at ironhack']\n", + "['ironhack is cool', 'i love ironhack', 'i am a student at ironhack']\n" + ] + } + ], + "source": [ + "# Write your code here\n", + "\n", + "corpus = str(corpus)\n", + "print(corpus)\n", + "\n", + "corpus2 = corpus.replace(\".\", \"\")\n", + "corpus3 = corpus2.lower()\n", + "print(corpus3)\n", + "\n", + "list(corpus3)\n", + "print(corpus3)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now define `bag_of_words` as an empty array. It will be used to store the unique terms in `corpus`." + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [], + "source": [ + "bag_of_words = [] " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Loop through `corpus`. In each loop, do the following:\n", + "\n", + "1. Break the string into an array of terms. \n", + "1. Create a sub-loop to iterate the terms array. \n", + " * In each sub-loop, you'll check if the current term is already contained in `bag_of_words`. If not in `bag_of_words`, append it to the array." + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\"['ironhack\", 'is', \"cool',\", \"'i\", 'love', \"ironhack',\", \"'i\", 'am', 'a', 'student', 'at', \"ironhack']\"]\n" + ] + }, + { + "data": { + "text/plain": [ + "{\"'i\",\n", + " \"['ironhack\",\n", + " 'a',\n", + " 'am',\n", + " 'at',\n", + " \"cool',\",\n", + " \"ironhack',\",\n", + " \"ironhack']\",\n", + " 'is',\n", + " 'love',\n", + " 'student'}" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Write your code here\n", + "\n", + "corpus4 = corpus3.split()\n", + "print(corpus4)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Print `bag_of_words`. You should see: \n", + "\n", + "```['ironhack', 'is', 'cool', 'i', 'love', 'am', 'a', 'student', 'at']```\n", + "\n", + "If not, fix your code in the previous cell." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(bag_of_words)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now we define an empty array called `term_freq`. Loop `corpus` for a second time. In each loop, create a sub-loop to iterate the terms in `bag_of_words`. Count how many times each term appears in each doc of `corpus`. Append the term-frequency array to `term_freq`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "term_freq = []\n", + "\n", + "# Write your code here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Print `term_freq`. You should see:\n", + "\n", + "```[[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 1, 1, 1, 1]]```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(term_freq)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**If your output is correct, congratulations! You've solved the challenge!**\n", + "\n", + "If not, go back and check for errors in your code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Bonus Question\n", + "\n", + "Optimize your solution for the above question by removing stop words from the BoW. For your convenience, a list of stop words is defined for you in the next cell. With the stop words removed, your output should look like:\n", + "\n", + "```\n", + "bag_of_words = [am', 'at', 'cool', ironhack', 'is', 'love', 'student']\n", + "\n", + "term_freq = [\n", + "\t[0, 0, 1, 1, 1, 0, 0],\n", + " \t[0, 0, 0, 1, 0, 1, 0],\n", + " \t[1, 1, 0, 1, 0, 0, 1]\n", + "]\n", + "```\n", + "\n", + "**Requirements:**\n", + "\n", + "1. Combine all your previous codes to the cell below.\n", + "1. Improve your solution by ignoring stop words in `bag_of_words`.\n", + "\n", + "After you're done, your `bag_of_words` should be:\n", + "\n", + "```['ironhack', 'is', 'cool', 'love', 'am', 'student', 'at']```\n", + "\n", + "And your `term_freq` should be:\n", + "\n", + "```[[1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1]]```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "stop_words = ['all', 'six', 'less', 'being', 'indeed', 'over', 'move', 'anyway', 'fifty', 'four', 'not', 'own', 'through', 'yourselves', 'go', 'where', 'mill', 'only', 'find', 'before', 'one', 'whose', 'system', 'how', 'somewhere', 'with', 'thick', 'show', 'had', 'enough', 'should', 'to', 'must', 'whom', 'seeming', 'under', 'ours', 'has', 'might', 'thereafter', 'latterly', 'do', 'them', 'his', 'around', 'than', 'get', 'very', 'de', 'none', 'cannot', 'every', 'whether', 'they', 'front', 'during', 'thus', 'now', 'him', 'nor', 'name', 'several', 'hereafter', 'always', 'who', 'cry', 'whither', 'this', 'someone', 'either', 'each', 'become', 'thereupon', 'sometime', 'side', 'two', 'therein', 'twelve', 'because', 'often', 'ten', 'our', 'eg', 'some', 'back', 'up', 'namely', 'towards', 'are', 'further', 'beyond', 'ourselves', 'yet', 'out', 'even', 'will', 'what', 'still', 'for', 'bottom', 'mine', 'since', 'please', 'forty', 'per', 'its', 'everything', 'behind', 'un', 'above', 'between', 'it', 'neither', 'seemed', 'ever', 'across', 'she', 'somehow', 'be', 'we', 'full', 'never', 'sixty', 'however', 'here', 'otherwise', 'were', 'whereupon', 'nowhere', 'although', 'found', 'alone', 're', 'along', 'fifteen', 'by', 'both', 'about', 'last', 'would', 'anything', 'via', 'many', 'could', 'thence', 'put', 'against', 'keep', 'etc', 'amount', 'became', 'ltd', 'hence', 'onto', 'or', 'con', 'among', 'already', 'co', 'afterwards', 'formerly', 'within', 'seems', 'into', 'others', 'while', 'whatever', 'except', 'down', 'hers', 'everyone', 'done', 'least', 'another', 'whoever', 'moreover', 'couldnt', 'throughout', 'anyhow', 'yourself', 'three', 'from', 'her', 'few', 'together', 'top', 'there', 'due', 'been', 'next', 'anyone', 'eleven', 'much', 'call', 'therefore', 'interest', 'then', 'thru', 'themselves', 'hundred', 'was', 'sincere', 'empty', 'more', 'himself', 'elsewhere', 'mostly', 'on', 'fire', 'am', 'becoming', 'hereby', 'amongst', 'else', 'part', 'everywhere', 'too', 'herself', 'former', 'those', 'he', 'me', 'myself', 'made', 'twenty', 'these', 'bill', 'cant', 'us', 'until', 'besides', 'nevertheless', 'below', 'anywhere', 'nine', 'can', 'of', 'your', 'toward', 'my', 'something', 'and', 'whereafter', 'whenever', 'give', 'almost', 'wherever', 'is', 'describe', 'beforehand', 'herein', 'an', 'as', 'itself', 'at', 'have', 'in', 'seem', 'whence', 'ie', 'any', 'fill', 'again', 'hasnt', 'inc', 'thereby', 'thin', 'no', 'perhaps', 'latter', 'meanwhile', 'when', 'detail', 'same', 'wherein', 'beside', 'also', 'that', 'other', 'take', 'which', 'becomes', 'you', 'if', 'nobody', 'see', 'though', 'may', 'after', 'upon', 'most', 'hereupon', 'eight', 'but', 'serious', 'nothing', 'such', 'why', 'a', 'off', 'whereby', 'third', 'i', 'whole', 'noone', 'sometimes', 'well', 'amoungst', 'yours', 'their', 'rather', 'without', 'so', 'five', 'the', 'first', 'whereas', 'once']\n", + "\n", + "# Write your code below\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Additional Challenge for the Nerds\n", + "\n", + "We will learn Scikit-Learn in Module 3 which has built in the BoW feature. Try to use Scikit-Learn to generate the BoW for this challenge and check whether the output is the same as yours. You will need to do some googling to find out how to use Scikit-Learn to generate BoW.\n", + "\n", + "**Notes:**\n", + "\n", + "* To install Scikit-Learn, use `pip install sklearn`. \n", + "\n", + "* Scikit-Learn removes stop words by default. You don't need to manually remove stop words.\n", + "\n", + "* Scikit-Learn's output has slightly different format from the output example demonstrated above. It's ok, you don't need to convert the Scikit-Learn output.\n", + "\n", + "The Scikit-Learn output will look like below:\n", + "\n", + "```python\n", + "# BoW:\n", + "{u'love': 5, u'ironhack': 3, u'student': 6, u'is': 4, u'cool': 2, u'am': 0, u'at': 1}\n", + "\n", + "# term_freq:\n", + "[[0 0 1 1 1 0 0]\n", + " [0 0 0 1 0 1 0]\n", + " [1 1 0 1 0 0 1]]\n", + " ```" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 4d10286580f0b845d6af521024c0447608db5d54 Mon Sep 17 00:00:00 2001 From: Ever77x Date: Wed, 6 Oct 2021 20:09:11 -0500 Subject: [PATCH 13/13] =?UTF-8?q?a=C3=B1adiendo=20lab1=20tuples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../your-code/challenge-1.ipynb | 218 +++++++++++++++--- 1 file changed, 189 insertions(+), 29 deletions(-) diff --git a/module-1/lab-tuple-set-dict/your-code/challenge-1.ipynb b/module-1/lab-tuple-set-dict/your-code/challenge-1.ipynb index 2e59d7714..7acc8508d 100644 --- a/module-1/lab-tuple-set-dict/your-code/challenge-1.ipynb +++ b/module-1/lab-tuple-set-dict/your-code/challenge-1.ipynb @@ -15,11 +15,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I',)\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "tup = tuple(\"I\",) \n", + "print(tup)\n" ] }, { @@ -33,11 +44,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "tuple" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "type(tup)" ] }, { @@ -55,13 +79,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['I', 'r', 'o', 'n', 'h', 'a', 'c', 'k']\n" + ] + } + ], "source": [ "# Your code here\n", "\n", - "# Your explanation here\n" + "tup = list(tup)\n", + "tup.append(\"r\")\n", + "tup.append(\"o\")\n", + "tup.append(\"n\")\n", + "tup.append(\"h\")\n", + "tup.append(\"a\")\n", + "tup.append(\"c\")\n", + "tup.append(\"k\")\n", + "\n", + "print(tup)\n", + "\n", + "\n", + "\n", + "# Your explanation here\n", + "\n", + "##realmente trate de convertir las letras en una lista o un string pero me apercia un () o un [] despues de \"I,\" y esta fue \n", + "## la forma en que pude corregir eso\n" ] }, { @@ -79,13 +127,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n", + "\n" + ] + } + ], "source": [ "# Your code here\n", "\n", - "# Your explanation here\n" + "tup = tuple(tup)\n", + "print(tup)\n", + "print(type(tup))\n", + "\n", + "# Your explanation here\n", + "\n", + "\n" ] }, { @@ -103,11 +166,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n')\n", + "('h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "tup1 = tup[0:4] \n", + "print(tup1)\n", + "\n", + "tup2 = tup[-4:]\n", + "print(tup2)" ] }, { @@ -121,11 +199,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "tup3 = tup1 + tup2\n", + "print(tup3)\n", + "\n", + "tup3 == tup\n", + "\n" ] }, { @@ -137,11 +239,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 69, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n", + "4\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "print(len(tup1))\n", + "print(len(tup2))\n", + "\n", + "((len(tup1)) + (len(tup2))) == len(tup3)" ] }, { @@ -153,11 +279,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'h'" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "tup3[4]" ] }, { @@ -177,11 +316,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 75, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['TRUE', 'FALSE', 'TRUE', 'FALSE', 'FALSE']\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n", + "answer = []\n", + "\n", + "for x in letters:\n", + " if x in tup3:\n", + " answer.append(\"TRUE\")\n", + " else:\n", + " answer.append(\"FALSE\")\n", + " \n", + "print(answer)\n", + "\n", + " \n" ] }, { @@ -219,9 +379,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.8" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }