From 24e9fe8e22033ceed6e432da9a3c12a33481b725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Thu, 30 Jul 2020 15:56:24 -0300 Subject: [PATCH 01/17] Created using Colaboratory --- Desafio_01.ipynb | 129 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 5 deletions(-) diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb index 49ee4db..4bf77da 100644 --- a/Desafio_01.ipynb +++ b/Desafio_01.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -67,7 +67,7 @@ "\n", "# Seu código" ], - "execution_count": 0, + "execution_count": null, "outputs": [] }, { @@ -78,10 +78,129 @@ "colab": {} }, "source": [ - "" + "import numpy as np\n", + "import pandas as pd" ], - "execution_count": 0, + "execution_count": 1, "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "aWNGRLDqEx8v", + "colab_type": "code", + "colab": {} + }, + "source": [ + "contab_list = [ 'red', 'green', 'black', 'pink', 'black', 'white',\n", + " 'black', 'eyes', 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',\n", + " 'white', \"black\", 'pink', 'green', 'green', 'pink', 'green', 'pink', 'white', 'orange', \"orange\", 'red' ]" + ], + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "k1u6Ft_XE3W9", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 266 + }, + "outputId": "5dd7cb8b-a22b-4bde-ed04-c1b26c8dde09" + }, + "source": [ + "df = pd.DataFrame({'cor':contab_list})\n", + "df['num'] = 1\n", + "df2 = df.groupby(['cor'],as_index=False).agg({'num':'count'}).sort_values(['num'],ascending=False)\n", + "df2" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
cornum
4pink6
0black5
6white5
2green4
3orange4
5red4
1eyes1
\n", + "
" + ], + "text/plain": [ + " cor num\n", + "4 pink 6\n", + "0 black 5\n", + "6 white 5\n", + "2 green 4\n", + "3 orange 4\n", + "5 red 4\n", + "1 eyes 1" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 3 + } + ] } ] -} +} \ No newline at end of file From 94c88505eea87fdd8089d2d8433c0a1ecc349f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Thu, 30 Jul 2020 16:08:56 -0300 Subject: [PATCH 02/17] Created using Colaboratory --- Desafio_02.ipynb | 53 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/Desafio_02.ipynb b/Desafio_02.ipynb index ee7f64b..af994e9 100644 --- a/Desafio_02.ipynb +++ b/Desafio_02.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -65,11 +65,54 @@ "colab": {} }, "source": [ - "def convert_to_sec(number):\n", - " pass # Seu código" + "#def convert_to_sec(number):\n", + " #pass # Seu código" ], - "execution_count": 0, + "execution_count": 1, "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "iljyjMOfH6I7", + "colab_type": "code", + "colab": {} + }, + "source": [ + "def convert_to_seconds(t):\n", + " seconds = t * 3600\n", + " return seconds" + ], + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "_hwFYX-zH8mA", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "outputId": "f59afb4d-196e-4e89-dc0e-41b1299b173b" + }, + "source": [ + "hours = int(input('How many hours do you want to convert into seconds? '))\n", + "\n", + "print(convert_to_seconds(hours))\n" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "text": [ + "How many hours do you want to convert into seconds? 10\n", + "36000\n" + ], + "name": "stdout" + } + ] } ] -} +} \ No newline at end of file From f59548883a977d9fc8b4387c7a5dba46446504f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Thu, 30 Jul 2020 16:11:26 -0300 Subject: [PATCH 03/17] Created using Colaboratory --- Desafio_02.ipynb | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/Desafio_02.ipynb b/Desafio_02.ipynb index af994e9..2be7041 100644 --- a/Desafio_02.ipynb +++ b/Desafio_02.ipynb @@ -65,44 +65,32 @@ "colab": {} }, "source": [ - "#def convert_to_sec(number):\n", - " #pass # Seu código" + "def convert_to_sec(number):\n", + " pass # Seu código" ], - "execution_count": 1, + "execution_count": null, "outputs": [] }, { "cell_type": "code", "metadata": { - "id": "iljyjMOfH6I7", - "colab_type": "code", - "colab": {} - }, - "source": [ - "def convert_to_seconds(t):\n", - " seconds = t * 3600\n", - " return seconds" - ], - "execution_count": 2, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "_hwFYX-zH8mA", + "id": "3MzoZgJJIh9V", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 51 }, - "outputId": "f59afb4d-196e-4e89-dc0e-41b1299b173b" + "outputId": "bf56533f-62cb-4c92-c555-467abd0b3b27" }, "source": [ + "def convert_to_seconds(t):\n", + " seconds = t * 3600\n", + " return seconds\n", "hours = int(input('How many hours do you want to convert into seconds? '))\n", "\n", - "print(convert_to_seconds(hours))\n" + "print(convert_to_seconds(hours))" ], - "execution_count": 3, + "execution_count": 5, "outputs": [ { "output_type": "stream", From 523c39d8b18a65ca98b04675c6b63318d734d02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Thu, 30 Jul 2020 16:14:44 -0300 Subject: [PATCH 04/17] Created using Colaboratory --- Desafio_03.ipynb | 53 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/Desafio_03.ipynb b/Desafio_03.ipynb index 1311cbd..00d661a 100644 --- a/Desafio_03.ipynb +++ b/Desafio_03.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -61,7 +61,7 @@ "\n", "# Seu código" ], - "execution_count": 0, + "execution_count": null, "outputs": [] }, { @@ -69,13 +69,52 @@ "metadata": { "id": "wo2rA-NriFtO", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "486ca1fe-f744-4879-b652-866a8a020a15" }, "source": [ - "" + "import numpy as np\n", + "lista = [1,2,3,4,3,30,3,4,5,6,9,3,2,1,2,4,5,15,6,6,3,13,4,45,5]\n", + "print(np.unique(lista))" ], - "execution_count": 0, - "outputs": [] + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[ 1 2 3 4 5 6 9 13 15 30 45]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "7yqVCMcfJXXi", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "5dc1d1b4-0d2b-45c5-8aed-780edbdf94b8" + }, + "source": [ + "print(-np.sort(-np.unique(lista)))" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[45 30 15 13 9 6 5 4 3 2 1]\n" + ], + "name": "stdout" + } + ] } ] -} +} \ No newline at end of file From ac7dd87d3f577a92cf812eb39b710ca9f4253932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 11:34:29 -0300 Subject: [PATCH 05/17] Criado usando o Colaboratory --- Desafio_01.ipynb | 71 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb index 4bf77da..3705108 100644 --- a/Desafio_01.ipynb +++ b/Desafio_01.ipynb @@ -67,7 +67,7 @@ "\n", "# Seu código" ], - "execution_count": null, + "execution_count": 3, "outputs": [] }, { @@ -81,7 +81,7 @@ "import numpy as np\n", "import pandas as pd" ], - "execution_count": 1, + "execution_count": 4, "outputs": [] }, { @@ -96,7 +96,7 @@ " 'black', 'eyes', 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',\n", " 'white', \"black\", 'pink', 'green', 'green', 'pink', 'green', 'pink', 'white', 'orange', \"orange\", 'red' ]" ], - "execution_count": 2, + "execution_count": 5, "outputs": [] }, { @@ -108,7 +108,7 @@ "base_uri": "https://localhost:8080/", "height": 266 }, - "outputId": "5dd7cb8b-a22b-4bde-ed04-c1b26c8dde09" + "outputId": "b623af18-b628-4f4f-a7c2-ed8c3ebbb9e3" }, "source": [ "df = pd.DataFrame({'cor':contab_list})\n", @@ -116,7 +116,7 @@ "df2 = df.groupby(['cor'],as_index=False).agg({'num':'count'}).sort_values(['num'],ascending=False)\n", "df2" ], - "execution_count": 3, + "execution_count": 6, "outputs": [ { "output_type": "execute_result", @@ -198,9 +198,68 @@ "metadata": { "tags": [] }, - "execution_count": 3 + "execution_count": 6 } ] + }, + { + "cell_type": "code", + "metadata": { + "id": "sq_6g4FD1guf", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 136 + }, + "outputId": "13e77b53-d870-4cc3-e264-877a8004666c" + }, + "source": [ + "import re\n", + "\n", + "my_string = 'red green black pink black white black eyes white black orange pink pink red red white orange white black pink green green pink green pink white orange orange red'\n", + "\n", + "words = re.findall(r'\\w+', my_string)\n", + "from collections import Counter\n", + "\n", + "cap_words = [word.upper() for word in words] #capitalizes all the words\n", + "\n", + "word_counts = Counter(cap_words)\n", + "word_counts" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "Counter({'BLACK': 5,\n", + " 'EYES': 1,\n", + " 'GREEN': 4,\n", + " 'ORANGE': 4,\n", + " 'PINK': 6,\n", + " 'RED': 4,\n", + " 'WHITE': 5})" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 7 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "Z4j92guN1i6-", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": null, + "outputs": [] } ] } \ No newline at end of file From 14f3cd01e13c4a7daa1a57fcbf62782df119ac74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 11:41:48 -0300 Subject: [PATCH 06/17] Criado usando o Colaboratory --- Desafio_01.ipynb | 53 +++++++++++------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb index 3705108..f942dfb 100644 --- a/Desafio_01.ipynb +++ b/Desafio_01.ipynb @@ -57,17 +57,15 @@ "colab": {} }, "source": [ + "# Solução via Data Frame\n", "palavras = [\n", " 'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',\n", " 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',\n", " 'white', \"black\", 'pink', 'green', 'green', 'pink', 'green', 'pink',\n", " 'white', 'orange', \"orange\", 'red'\n", - "]\n", - "\n", - "\n", - "# Seu código" + "]\n" ], - "execution_count": 3, + "execution_count": 11, "outputs": [] }, { @@ -81,22 +79,7 @@ "import numpy as np\n", "import pandas as pd" ], - "execution_count": 4, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "aWNGRLDqEx8v", - "colab_type": "code", - "colab": {} - }, - "source": [ - "contab_list = [ 'red', 'green', 'black', 'pink', 'black', 'white',\n", - " 'black', 'eyes', 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',\n", - " 'white', \"black\", 'pink', 'green', 'green', 'pink', 'green', 'pink', 'white', 'orange', \"orange\", 'red' ]" - ], - "execution_count": 5, + "execution_count": 12, "outputs": [] }, { @@ -108,15 +91,15 @@ "base_uri": "https://localhost:8080/", "height": 266 }, - "outputId": "b623af18-b628-4f4f-a7c2-ed8c3ebbb9e3" + "outputId": "42e29cb1-9eb2-4331-f95d-e81f640a193b" }, "source": [ - "df = pd.DataFrame({'cor':contab_list})\n", + "df = pd.DataFrame({'cor':palavras})\n", "df['num'] = 1\n", "df2 = df.groupby(['cor'],as_index=False).agg({'num':'count'}).sort_values(['num'],ascending=False)\n", "df2" ], - "execution_count": 6, + "execution_count": 13, "outputs": [ { "output_type": "execute_result", @@ -198,7 +181,7 @@ "metadata": { "tags": [] }, - "execution_count": 6 + "execution_count": 13 } ] }, @@ -211,9 +194,10 @@ "base_uri": "https://localhost:8080/", "height": 136 }, - "outputId": "13e77b53-d870-4cc3-e264-877a8004666c" + "outputId": "4efb57e9-7190-4e91-8096-b399b0f88ff2" }, "source": [ + "# Solução via RE\n", "import re\n", "\n", "my_string = 'red green black pink black white black eyes white black orange pink pink red red white orange white black pink green green pink green pink white orange orange red'\n", @@ -226,7 +210,7 @@ "word_counts = Counter(cap_words)\n", "word_counts" ], - "execution_count": 7, + "execution_count": 16, "outputs": [ { "output_type": "execute_result", @@ -244,22 +228,9 @@ "metadata": { "tags": [] }, - "execution_count": 7 + "execution_count": 16 } ] - }, - { - "cell_type": "code", - "metadata": { - "id": "Z4j92guN1i6-", - "colab_type": "code", - "colab": {} - }, - "source": [ - "" - ], - "execution_count": null, - "outputs": [] } ] } \ No newline at end of file From 6858a66da02f9560a50dc2cb26ed813ea9828c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 11:53:36 -0300 Subject: [PATCH 07/17] Criado usando o Colaboratory --- Desafio_01.ipynb | 51 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb index f942dfb..e5d8401 100644 --- a/Desafio_01.ipynb +++ b/Desafio_01.ipynb @@ -65,7 +65,7 @@ " 'white', 'orange', \"orange\", 'red'\n", "]\n" ], - "execution_count": 11, + "execution_count": 17, "outputs": [] }, { @@ -79,7 +79,7 @@ "import numpy as np\n", "import pandas as pd" ], - "execution_count": 12, + "execution_count": 18, "outputs": [] }, { @@ -91,7 +91,7 @@ "base_uri": "https://localhost:8080/", "height": 266 }, - "outputId": "42e29cb1-9eb2-4331-f95d-e81f640a193b" + "outputId": "9f1b5ce8-d148-40bc-ed94-9235e2fb873a" }, "source": [ "df = pd.DataFrame({'cor':palavras})\n", @@ -99,7 +99,7 @@ "df2 = df.groupby(['cor'],as_index=False).agg({'num':'count'}).sort_values(['num'],ascending=False)\n", "df2" ], - "execution_count": 13, + "execution_count": 19, "outputs": [ { "output_type": "execute_result", @@ -181,7 +181,42 @@ "metadata": { "tags": [] }, - "execution_count": 13 + "execution_count": 19 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "4FuxyViJ55-g", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 136 + }, + "outputId": "fffd92b0-c17a-4dad-97b9-b91c1c59ed36" + }, + "source": [ + "# Solução via set\n", + "palavras_set = set(palavras)\n", + "palavras_set\n", + "for i in palavras_set:\n", + " print(i,palavras.count(i))" + ], + "execution_count": 20, + "outputs": [ + { + "output_type": "stream", + "text": [ + "green 4\n", + "black 5\n", + "orange 4\n", + "red 4\n", + "white 5\n", + "pink 6\n", + "eyes 1\n" + ], + "name": "stdout" } ] }, @@ -194,7 +229,7 @@ "base_uri": "https://localhost:8080/", "height": 136 }, - "outputId": "4efb57e9-7190-4e91-8096-b399b0f88ff2" + "outputId": "856311b3-5935-468c-b9ad-441d335e9092" }, "source": [ "# Solução via RE\n", @@ -210,7 +245,7 @@ "word_counts = Counter(cap_words)\n", "word_counts" ], - "execution_count": 16, + "execution_count": 21, "outputs": [ { "output_type": "execute_result", @@ -228,7 +263,7 @@ "metadata": { "tags": [] }, - "execution_count": 16 + "execution_count": 21 } ] } From 115a4d0726e46322971faa7d054947ea6c06f1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 12:03:28 -0300 Subject: [PATCH 08/17] Criado usando o Colaboratory --- Desafio_03.ipynb | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/Desafio_03.ipynb b/Desafio_03.ipynb index 00d661a..034041b 100644 --- a/Desafio_03.ipynb +++ b/Desafio_03.ipynb @@ -57,11 +57,10 @@ "colab": {} }, "source": [ - "lista = [1,2,3,4,3,30,3,4,5,6,9,3,2,1,2,4,5,15,6,6,3,13,4,45,5]\n", - "\n", - "# Seu código" + "# Usando o unique\n", + "lista = [1,2,3,4,3,30,3,4,5,6,9,3,2,1,2,4,5,15,6,6,3,13,4,45,5]\n" ], - "execution_count": null, + "execution_count": 1, "outputs": [] }, { @@ -73,7 +72,7 @@ "base_uri": "https://localhost:8080/", "height": 34 }, - "outputId": "486ca1fe-f744-4879-b652-866a8a020a15" + "outputId": "ec7f1a7f-ae06-41b3-94ae-d61de535a349" }, "source": [ "import numpy as np\n", @@ -100,7 +99,7 @@ "base_uri": "https://localhost:8080/", "height": 34 }, - "outputId": "5dc1d1b4-0d2b-45c5-8aed-780edbdf94b8" + "outputId": "966601f4-080a-4ca2-db27-703b1dbcb11a" }, "source": [ "print(-np.sort(-np.unique(lista)))" @@ -115,6 +114,38 @@ "name": "stdout" } ] + }, + { + "cell_type": "code", + "metadata": { + "id": "EuqyYQg_75Ug", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "df1c3cc1-82f5-4923-f837-f8d4e562bb70" + }, + "source": [ + "# Usando o set\n", + "lista_set = set(lista)\n", + "lista_set\n" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45}" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 7 + } + ] } ] } \ No newline at end of file From 39f20c50012e0746ed26f25a140a8f7034a42cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 13:33:45 -0300 Subject: [PATCH 09/17] Criado usando o Colaboratory --- Desafio_04.ipynb | 52 ++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/Desafio_04.ipynb b/Desafio_04.ipynb index 089c3a8..a63eb9d 100644 --- a/Desafio_04.ipynb +++ b/Desafio_04.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -58,26 +58,40 @@ "metadata": { "id": "I5TInJDaf6JW", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "outputId": "27992a7d-a31d-4ba5-d173-e3704192be1d" }, "source": [ - "# Seu código" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "6gq9SLl1xSV1", - "colab_type": "code", - "colab": {} - }, - "source": [ - "" + "frase = ' Python é legal'\n", + "def inverte_texto(frase):\n", + " quebrada = frase.split()\n", + " invertida = quebrada[::-1]\n", + " final = ' '.join(invertida)\n", + " return final\n", + "\n", + "inverte_texto(frase)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 2, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "'legal é Python'" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 2 + } + ] } ] -} +} \ No newline at end of file From 0c18d1beca67dd192fffaaff478ff6a028b87eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 13:39:55 -0300 Subject: [PATCH 10/17] Criado usando o Colaboratory --- Desafio_05.ipynb | 188 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 180 insertions(+), 8 deletions(-) diff --git a/Desafio_05.ipynb b/Desafio_05.ipynb index 204b1df..7a03f40 100644 --- a/Desafio_05.ipynb +++ b/Desafio_05.ipynb @@ -5,7 +5,6 @@ "colab": { "name": "Desafio 5.ipynb", "provenance": [], - "authorship_tag": "ABX9TyO0u4amKtoFgAgnb/IGUddy", "include_colab_link": true }, "kernelspec": { @@ -21,7 +20,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -68,7 +67,7 @@ "'(255) 826-9050',\n", "]" ], - "execution_count": 0, + "execution_count": 1, "outputs": [] }, { @@ -86,13 +85,186 @@ "metadata": { "id": "F8n1sN-4XrW3", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 272 + }, + "outputId": "98a20d1e-885e-4919-866d-d91d76c1eb88" }, "source": [ - "" + "# Solução com set\n", + "lsita_sem_duplicados = set(numeros_telefone)\n", + "lsita_sem_duplicados" ], - "execution_count": 0, - "outputs": [] + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'(255) 826-9050',\n", + " '(285) 608-2448',\n", + " '(311) 799-3883',\n", + " '(410) 665-4447',\n", + " '(464) 788-2397',\n", + " '(511) 821-7870',\n", + " '(554) 994-1517',\n", + " '(596) 336-5508',\n", + " '(650) 684-1437',\n", + " '(765) 368-1506',\n", + " '(812) 816-0881',\n", + " '(821) 642-8987',\n", + " '(885) 407-1719',\n", + " '(935) 875-2054',\n", + " '(943) 769-1061'}" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 3 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "eE8kj1LaSJJJ", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 514 + }, + "outputId": "5d88f2ad-1167-4413-ad16-05d87a53c49c" + }, + "source": [ + "# Solução com Data Frame\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "df = pd.DataFrame({'numeros_telefone':numeros_telefone})\n", + "df['num'] = 1\n", + "df2 = df.groupby(['numeros_telefone'],as_index=False).agg({'num':'count'}).sort_values(['num'],ascending=False)\n", + "df3 = df2[['numeros_telefone']].reset_index(drop=True)\n", + "df3" + ], + "execution_count": 7, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
numeros_telefone
0(285) 608-2448
1(765) 368-1506
2(255) 826-9050
3(596) 336-5508
4(311) 799-3883
5(410) 665-4447
6(464) 788-2397
7(511) 821-7870
8(554) 994-1517
9(650) 684-1437
10(812) 816-0881
11(821) 642-8987
12(885) 407-1719
13(935) 875-2054
14(943) 769-1061
\n", + "
" + ], + "text/plain": [ + " numeros_telefone\n", + "0 (285) 608-2448\n", + "1 (765) 368-1506\n", + "2 (255) 826-9050\n", + "3 (596) 336-5508\n", + "4 (311) 799-3883\n", + "5 (410) 665-4447\n", + "6 (464) 788-2397\n", + "7 (511) 821-7870\n", + "8 (554) 994-1517\n", + "9 (650) 684-1437\n", + "10 (812) 816-0881\n", + "11 (821) 642-8987\n", + "12 (885) 407-1719\n", + "13 (935) 875-2054\n", + "14 (943) 769-1061" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 7 + } + ] } ] -} +} \ No newline at end of file From 02bc99c2f16e1c640c72912e63e89d80f011d0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 13:50:28 -0300 Subject: [PATCH 11/17] Criado usando o Colaboratory --- Desafio_06.ipynb | 130 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 120 insertions(+), 10 deletions(-) diff --git a/Desafio_06.ipynb b/Desafio_06.ipynb index 4508023..d3d88df 100644 --- a/Desafio_06.ipynb +++ b/Desafio_06.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -60,26 +60,136 @@ "metadata": { "id": "mvxpy_vCf6Jh", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "1553ffc6-3a70-412a-fee6-2d4850b426aa" }, "source": [ - "# Seu código" + "# Usando set\n", + "a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n", + "b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n", + "def inter(lista_a,lista_b):\n", + " inter = set(lista_a) & set(lista_b)\n", + " inter_final = list(inter)\n", + " return inter_final\n", + "inter(b,a)\n" ], - "execution_count": 0, - "outputs": [] + "execution_count": 2, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 5, 8, 13]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 2 + } + ] }, { "cell_type": "code", "metadata": { "id": "ly-N_Aq624RQ", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 235 + }, + "outputId": "d871c1b6-a4d6-477a-b016-06622836585b" }, "source": [ - "" + "# Usando Data Frame\n", + "import numpy as np\n", + "import pandas as pd\n", + "a_df = pd.DataFrame({'Coluna A':a}).drop_duplicates()\n", + "b_df = pd.DataFrame({'Coluna B':b}).drop_duplicates()\n", + "#print(a_df)\n", + "#print(b_df)\n", + "#c_df = pd.merge(a_df,b_df,how = 'inner',left_on = 'Coluna A', right_on= 'Coluna B',validate = '1:1')\n", + "#c_df\n", + "a_df_u = pd.DataFrame({'Única':a}).drop_duplicates()\n", + "b_df_u = pd.DataFrame({'Única':b}).drop_duplicates()\n", + "c_df = pd.merge(a_df_u,b_df_u,how = 'inner',on='Única',validate = '1:1')\n", + "c_df" ], - "execution_count": 0, - "outputs": [] + "execution_count": 4, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Única
01
12
23
35
48
513
\n", + "
" + ], + "text/plain": [ + " Única\n", + "0 1\n", + "1 2\n", + "2 3\n", + "3 5\n", + "4 8\n", + "5 13" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 4 + } + ] } ] -} +} \ No newline at end of file From 1477817b0e320fa77a7c9e9343df338d71b065c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 14:07:21 -0300 Subject: [PATCH 12/17] Criado usando o Colaboratory --- Desafio_07.ipynb | 98 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 9 deletions(-) diff --git a/Desafio_07.ipynb b/Desafio_07.ipynb index 5107d99..b0cebc1 100644 --- a/Desafio_07.ipynb +++ b/Desafio_07.ipynb @@ -5,7 +5,6 @@ "colab": { "name": "Desafio 7.ipynb", "provenance": [], - "authorship_tag": "ABX9TyPinyzdF60Dyi+YfEQiCPfO", "include_colab_link": true }, "kernelspec": { @@ -21,7 +20,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -58,7 +57,7 @@ " '(228) 976-9699', '(757) 450-9985', '(491) 666-5367',\n", " ]" ], - "execution_count": 0, + "execution_count": 4, "outputs": [] }, { @@ -89,7 +88,7 @@ " '(822) 640-8496', '(227) 389-3685', '(429) 264-7427', \n", " '(397) 845-8267']" ], - "execution_count": 0, + "execution_count": 5, "outputs": [] }, { @@ -107,13 +106,94 @@ "metadata": { "id": "_OSrDQ1noh62", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 255 + }, + "outputId": "fe353633-fecf-4607-c237-098d9eeba5b1" }, "source": [ - "" + "# Solução usando for e append\n", + "import numpy as np\n", + "import pandas as pd\n", + "nao_entraram = []\n", + "for i in telefones_alunos:\n", + " if i in entraram_no_grupo:\n", + " pass\n", + " else:\n", + " nao_entraram = np.append(nao_entraram,i)\n", + " print (i)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "text": [ + "(873) 810-8267\n", + "(300) 303-5462\n", + "(941) 225-3869\n", + "(294) 430-7720\n", + "(835) 955-1498\n", + "(897) 932-2512\n", + "(640) 427-2597\n", + "(856) 338-7094\n", + "(641) 367-5279\n", + "(964) 710-9625\n", + "(403) 343-7705\n", + "(797) 649-3653\n", + "(757) 450-9985\n", + "(491) 666-5367\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "sIVz0zmdYYX4", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 255 + }, + "outputId": "3c94d2fd-6b1c-42dd-8a0a-8db336e902d7" + }, + "source": [ + "#Solução usando set\n", + "lista_nao_entraram = set(telefones_alunos) - set(entraram_no_grupo)\n", + "#type(set_alunos)\n", + "#lista_nao_entraram = list(set_alunos)\n", + "lista_nao_entraram" + ], + "execution_count": 9, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'(294) 430-7720',\n", + " '(300) 303-5462',\n", + " '(403) 343-7705',\n", + " '(491) 666-5367',\n", + " '(640) 427-2597',\n", + " '(641) 367-5279',\n", + " '(757) 450-9985',\n", + " '(797) 649-3653',\n", + " '(835) 955-1498',\n", + " '(856) 338-7094',\n", + " '(873) 810-8267',\n", + " '(897) 932-2512',\n", + " '(941) 225-3869',\n", + " '(964) 710-9625'}" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 9 + } + ] } ] -} +} \ No newline at end of file From ef5f6fe30c262e9e85acd813b8fb75f8096c2ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 14:33:56 -0300 Subject: [PATCH 13/17] Criado usando o Colaboratory --- Desafio_08.ipynb | 211 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 203 insertions(+), 8 deletions(-) diff --git a/Desafio_08.ipynb b/Desafio_08.ipynb index c6fed05..9d2e426 100644 --- a/Desafio_08.ipynb +++ b/Desafio_08.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -48,7 +48,10 @@ "\n", "Escreva um script Python para encontrar as 10 palavras mais longas em um arquivo.\n", "\n", - "O arquivo TXT está localizado na mesma pasta do projeto (texto.txt)." + "O arquivo TXT está localizado na mesma pasta do projeto (texto.txt).\n", + "(texto.txt). texto.txt =\n", + "What is Python language?\n", + "Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with Python." ] }, { @@ -56,13 +59,205 @@ "metadata": { "id": "EknxjSG0f6Jo", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 419 + }, + "outputId": "ade2e496-1e9e-4241-ae52-5a78dde37b00" }, "source": [ - "# Seu código" + "#Solução com Data Frame\n", + "import numpy as np\n", + "import pandas as pd\n", + "texto = 'Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with Python.'\n", + "proibidos = ',.()'\n", + "for elemento in proibidos:\n", + " texto = texto.replace(elemento,' ')\n", + "novo_texto = texto.split()\n", + "func_vect_len = np.vectorize(len)\n", + "texto_tamanho = func_vect_len(novo_texto)\n", + "#print(texto_tamanho)\n", + "#df = pd.DataFrame({'palavras':novo_texto,'dimensao':texto_tamanho}).sort_values('dimensao',ascending=False)[0:10]\n", + "#df = pd.DataFrame({'palavras':novo_texto,'dimensao':texto_tamanho}).sort_values('dimensao',ascending=False).head(10)\n", + "#df = pd.DataFrame({'palavras':novo_texto,'dimensao':texto_tamanho}).sort_values('dimensao',ascending=False).tail(10)\n", + "df = pd.DataFrame({'palavras':novo_texto,'dimensao':texto_tamanho}).sort_values('dimensao',ascending=False)\n", + "#df.info() # ter uma ideia de quantidade de colunas, dados faltantes, espaço memória\n", + "#df.describe() # nos dá uma ideia estatística da amostra\n", + "df\n" ], - "execution_count": 0, - "outputs": [] + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
palavrasdimensao
45object-oriented15
6general-purpose15
68comprehensive13
92intermediate12
49programming11
.........
53It2
74we2
65a1
55a1
2a1
\n", + "

98 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " palavras dimensao\n", + "45 object-oriented 15\n", + "6 general-purpose 15\n", + "68 comprehensive 13\n", + "92 intermediate 12\n", + "49 programming 11\n", + ".. ... ...\n", + "53 It 2\n", + "74 we 2\n", + "65 a 1\n", + "55 a 1\n", + "2 a 1\n", + "\n", + "[98 rows x 2 columns]" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 3 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "sjpXsL14ejBh", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 374 + }, + "outputId": "07a158fc-e21a-40a9-84d1-70455ea84b0a" + }, + "source": [ + "# Solução usando !wget, open e sorted\n", + "!wget https://raw.githubusercontent.com/awarischool/br-python-challenges/master/texto.txt\n", + "with open('texto.txt', 'r') as txt:\n", + " texto = txt.read().replace('.',' ').replace('?',' ').replace(',',' ').split()\n", + "lista_ordenada = sorted(texto,key=len,reverse=True)[:10]\n", + "lista_ordenada" + ], + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "text": [ + "--2020-08-17 17:33:19-- https://raw.githubusercontent.com/awarischool/br-python-challenges/master/texto.txt\n", + "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n", + "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n", + "HTTP request sent, awaiting response... 200 OK\n", + "Length: 766 [text/plain]\n", + "Saving to: ‘texto.txt’\n", + "\n", + "\rtexto.txt 0%[ ] 0 --.-KB/s \rtexto.txt 100%[===================>] 766 --.-KB/s in 0s \n", + "\n", + "2020-08-17 17:33:20 (35.9 MB/s) - ‘texto.txt’ saved [766/766]\n", + "\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "['general-purpose',\n", + " 'object-oriented',\n", + " 'comprehensive',\n", + " 'intermediate)',\n", + " 'interpreted',\n", + " 'programming',\n", + " 'readability',\n", + " 'programmers',\n", + " 'programming',\n", + " 'programming']" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 4 + } + ] }, { "cell_type": "code", @@ -74,8 +269,8 @@ "source": [ "" ], - "execution_count": 0, + "execution_count": null, "outputs": [] } ] -} +} \ No newline at end of file From 0773c338445005fd48acca3fc31e2a4a90ff43f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 14:51:45 -0300 Subject: [PATCH 14/17] Criado usando o Colaboratory --- Desafio_09.ipynb | 123 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 9 deletions(-) diff --git a/Desafio_09.ipynb b/Desafio_09.ipynb index 1426b31..8b596f0 100644 --- a/Desafio_09.ipynb +++ b/Desafio_09.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -57,23 +57,128 @@ "colab": {} }, "source": [ - "# Seu código" + "# Usando append\n", + "def multiplos(limite):\n", + " lista = []\n", + " for i in range(limite):\n", + " x = i*3\n", + " y = i*5\n", + " lista.append(x)\n", + " lista.append(y)\n", + " lista_limitada = sorted(i for i in lista if i <=limite)\n", + " lista_soma = sum(lista_limitada)\n", + " return lista_soma\n", + " #multiplos(20)\n", + " \n" ], - "execution_count": 0, + "execution_count": 14, "outputs": [] }, { "cell_type": "code", "metadata": { - "id": "a_6aqcKp6wrN", + "id": "6TO0TNmyisvE", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "5b491865-822a-4dc9-92a4-71770db985c2" }, "source": [ - "" + "multiplos(20)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 16, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "93" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 16 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "KVf_Pa0qh21E", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "outputId": "3f6d9b7f-596b-45e6-c40b-8923022d4c0a" + }, + "source": [ + "# Usando arange\n", + "import numpy as np\n", + "import pandas as pd\n", + "a= int(input('Digite um número para encontrarmos os múltiplos de 3 ou 5: '))\n", + "def soma_mult_3_5(numero):\n", + " arr = np.arange(1,numero+1) # arr é um array que vai de 1 até o número a que iremos inputar; 1,2,3,4,5,6... a\n", + " resultado = arr[(arr%3 == 0) | (arr%5 == 0)] # filtrando o array com as condições de divisão por 3 e 5 serão armazenados no array resultado\n", + " soma_resultado = np.sum(resultado)\n", + " return soma_resultado\n", + "soma_mult_3_5(a)" + ], + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Digite um número para encontrarmos os múltiplos de 3 ou 5: 20\n" + ], + "name": "stdout" + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "98" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 12 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "9Ge1_lWwiZ7-", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "becc8c9e-fae7-4f5c-b350-0994b41e8990" + }, + "source": [ + "3+ 5+ 6+ 9+ 10+ 12+ 15+ 18+20" + ], + "execution_count": 13, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "98" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 13 + } + ] } ] -} +} \ No newline at end of file From a72baa8ac050887a70d46fcc7f4e38e6c347bec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 15:04:15 -0300 Subject: [PATCH 15/17] Criado usando o Colaboratory --- Desafio_10.ipynb | 80 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/Desafio_10.ipynb b/Desafio_10.ipynb index 0ed40b5..3f3179a 100644 --- a/Desafio_10.ipynb +++ b/Desafio_10.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -64,12 +64,61 @@ "metadata": { "id": "IJ70pUjnf6Jw", "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "cedac1ff-f04f-4d7c-b795-187aedd53e0d" + }, + "source": [ + "# Usando len e reverse\n", + "import numpy as np\n", + "import pandas as pd\n", + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n", + "#sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89,100,101,102]\n", + "quant = len(sampleList)\n", + "if (quant%3 ==0):\n", + " tamanho_particao = int(quant/3)\n", + " lista_um=sampleList[0:tamanho_particao]\n", + " lista_dois=sampleList[tamanho_particao:tamanho_particao*2]\n", + " lista_tres=sampleList[tamanho_particao*2:]\n", + " lista_um.reverse()\n", + " lista_dois.reverse()\n", + " lista_tres.reverse()\n", + " #inverter + else\n", + " print((lista_um),(lista_dois),(lista_tres))\n", + "else:\n", + " print('A lista não é múltipla de 3')" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[8, 45, 11] [12, 14, 23] [89, 45, 78]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "4A1XiSy3lXTH", + "colab_type": "code", "colab": {} }, "source": [ - "# Seu código" + "# usando len\n", + "def quebra_inverte(lista):\n", + " terco_1 = int(len(lista)/3)\n", + " terco_2 = terco_1*2\n", + " parada_1 = lista[0:terco_1]\n", + " parada_2 = lista[terco_1:terco_2]\n", + " parada_3 = lista[terco_2:]\n", + " return parada_1[::-1],parada_2[::-1],parada_3[::-1]," ], - "execution_count": 0, + "execution_count": 5, "outputs": [] }, { @@ -77,13 +126,30 @@ "metadata": { "id": "pNrXNVqf8Wc1", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "f91f91c5-62a4-437c-f3e5-260ccc6c4490" }, "source": [ - "" + "quebra_inverte(sampleList)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 4, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "([8, 45, 11], [12, 14, 23], [89, 45, 78])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 4 + } + ] } ] } \ No newline at end of file From 9c980bfc53737dc6c5e86bdd35456720045c07ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 15:13:32 -0300 Subject: [PATCH 16/17] Criado usando o Colaboratory --- Desafio_11.ipynb | 129 ++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 64 deletions(-) diff --git a/Desafio_11.ipynb b/Desafio_11.ipynb index aa23e34..79165ab 100644 --- a/Desafio_11.ipynb +++ b/Desafio_11.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -60,11 +60,18 @@ "colab": {} }, "source": [ - "# Seu código\n", - "def contar_pares_impares(entrada):\n", - " pass" + "# Usando tupla\n", + "def par_e_impar(lista_numeros):\n", + " pares = 0\n", + " impares = 0\n", + " for num in lista_numeros:\n", + " if num % 2 == 0:\n", + " pares = pares+1\n", + " else:\n", + " impares= impares+1\n", + " return tuple((pares,impares))" ], - "execution_count": 0, + "execution_count": 1, "outputs": [] }, { @@ -72,77 +79,71 @@ "metadata": { "id": "OQG6erslSjri", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "50d84ca4-1c83-42eb-d6f7-39533231ac6a" }, "source": [ - "" + "sequencia = [6, 2, 7, -5, 8, -4]\n", + "par_e_impar(sequencia)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(4, 2)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 3 + } + ] }, { "cell_type": "code", "metadata": { "id": "BSuBza0GSjyM", "colab_type": "code", - "colab": {} - }, - "source": [ - "" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "y_iM2tgF35t7", - "colab_type": "code", - "colab": {} - }, - "source": [ - "# Não modifique o código abaixo! Vamos testar algumas entradas\n", - "msg_erro = \"Saída da função para a entrada {} deveria ser {}\"\n", - "\n", - "entrada = [6, 2, 7, -5, 8, -4]\n", - "saida_esperada = (4, 2)\n", - "assert contar_pares_impares(entrada)==saida_esperada, msg_erro.format(entrada, saida_esperada)\n", - "\n", - "entrada = [-3, 2, 7, -5, 8, -4]\n", - "saida_esperada = (3, 3)\n", - "assert contar_pares_impares(entrada)==saida_esperada, msg_erro.format(entrada, saida_esperada)\n", - "\n", - "\n", - "# Se nenhuma mensagem for impressa abaixo, significa que a função está implementada corretamente" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "Nfb7lBpq35_6", - "colab_type": "code", - "colab": {} - }, - "source": [ - "" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "UwT4tLtzR3_U", - "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "a73e401d-7469-4c6d-fd61-4d480ddf0c54" }, "source": [ - "" + "# Usando base de dados grande via random\n", + "#par_impar = [6, 2, 7, -5, 8, -4]\n", + "import numpy as np\n", + "import pandas as pd\n", + "par_impar = np.random.randint(0,4000,1000)\n", + "count_par = 0\n", + "count_impar = 0\n", + "for i in par_impar:\n", + " if i % 2 == 0:\n", + " count_par = count_par +1\n", + " #print('par')\n", + " else:\n", + " count_impar = count_impar + 1\n", + " #print('impar')\n", + "resultado = (count_par, count_impar)\n", + "print(resultado)" ], - "execution_count": 0, - "outputs": [] + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "text": [ + "(518, 482)\n" + ], + "name": "stdout" + } + ] } ] } \ No newline at end of file From 840c44c670df55ac94fe1dbb6b6506f452158f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20de=20Siqueira=20Frascino?= Date: Mon, 17 Aug 2020 15:24:39 -0300 Subject: [PATCH 17/17] Criado usando o Colaboratory --- Desafio_12.ipynb | 162 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 155 insertions(+), 7 deletions(-) diff --git a/Desafio_12.ipynb b/Desafio_12.ipynb index 0ebd52a..0115d8b 100644 --- a/Desafio_12.ipynb +++ b/Desafio_12.ipynb @@ -34,7 +34,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -71,12 +71,107 @@ "metadata": { "id": "UGgtGYGGf6J3", "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 306 + }, + "outputId": "804544a7-838d-468a-895c-30312025a70d" + }, + "source": [ + "# Usando caracter do numpy\n", + "import numpy as np\n", + "import pandas as pd\n", + "#senha_input = input('Digite uma senha que contenha entre 6 e 16 caracteres, 1 letra minúscula, 1 maiúscula, 1 número e 1 caracter especial: ')\n", + "senha_input = [\"12345678\", \"J3sus0\", \"#Te5t300\", \"J*90j12374\", \"Michheeul\", \"Monk3y6\",\"Qw#1234\"]\n", + "#for caracter in senha:\n", + " #print(caracter.isdigit())\n", + "#any(caracter.isdigit() for caracter in senha) # any:retorna verdadeiro se qquer valor da condição for verdadeiro\n", + "#not any(caracter.isdigit() for caracter in senha) # not any: retorna falso se qquer valor da condição for verdadeiro\n", + "def senha_valida(senha):\n", + " caracteres_especiais = ['$','#','@']\n", + " variavel_dummy = True\n", + "\n", + " if len(senha) < 6:\n", + " variavel_dummy = False\n", + " print('Senha inválida por ter menos que 6 digitos')\n", + " if len(senha) > 16:\n", + " variavel_dummy = False\n", + " print('Senha inválida por ter mais que 16 digitos')\n", + " if not any(caracter.isdigit() for caracter in senha):\n", + " variavel_dummy = False\n", + " print('Senha inválida por não possuir nenhum número')\n", + " if not any(caracter.islower() for caracter in senha):\n", + " variavel_dummy = False\n", + " print('Senha inválida por não possuir nenhuma letra minúscula')\n", + " if not any(caracter.isupper() for caracter in senha):\n", + " variavel_dummy = False\n", + " print('Senha inválida por não possuir nenhuma letra maiúscula')\n", + " if not any(caracter in caracteres_especiais for caracter in senha):\n", + " variavel_dummy = False\n", + " print('Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@')\n", + " if variavel_dummy == True:\n", + " print('Senha Válida')\n", + " \n", + "#senha_valida(senha in senha_input for senha in [6])\n", + "for r in senha_input:\n", + " print(r)\n", + " senha_valida(senha = r)" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "text": [ + "12345678\n", + "Senha inválida por não possuir nenhuma letra minúscula\n", + "Senha inválida por não possuir nenhuma letra maiúscula\n", + "Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@\n", + "J3sus0\n", + "Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@\n", + "#Te5t300\n", + "Senha Válida\n", + "J*90j12374\n", + "Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@\n", + "Michheeul\n", + "Senha inválida por não possuir nenhum número\n", + "Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@\n", + "Monk3y6\n", + "Senha inválida por não possuir um dos seguintes caracteres especiais: $,#,@\n", + "Qw#1234\n", + "Senha Válida\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "KrL-w8eDp19c", + "colab_type": "code", "colab": {} }, "source": [ - "# Seu código" + "# Usando string\n", + "import string\n", + "def verifica_senha(senha):\n", + " import string\n", + " especiais = [\"$\",\"#\",\"@\"]\n", + " minusculas = list(string.ascii_lowercase)\n", + " maiusculas = list(string.ascii_uppercase)\n", + " range_list = [str(i) for i in range(10)]\n", + " if len(senha) < 6 or len(senha) > 16:\n", + " return \"Senha Inválida\"\n", + " elif len(set(senha) & set(minusculas)) == 0:\n", + " return \"Senha inválida\"\n", + " elif len(set(senha) & set(maiusculas)) == 0:\n", + " return \"Senha inválida\"\n", + " elif len(set(senha) & set(range_list)) == 0:\n", + " return \"Senha inválida\"\n", + " else: \n", + " return\"Senha válida\"" ], - "execution_count": 0, + "execution_count": 5, "outputs": [] }, { @@ -84,13 +179,66 @@ "metadata": { "id": "n8F01NzD9uHm", "colab_type": "code", - "colab": {} + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "outputId": "7bd0df76-c7cf-4b7e-cf73-318aa646e613" }, "source": [ - "" + "verifica_senha('sE1#tgh')" ], - "execution_count": 0, - "outputs": [] + "execution_count": 6, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "'Senha válida'" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 6 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "mzPDaQIuqcz5", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "outputId": "9e2c40a9-c55a-48e5-ed30-0e06ee124cb8" + }, + "source": [ + "verifica_senha('1234')" + ], + "execution_count": 8, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "'Senha Inválida'" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 8 + } + ] } ] } \ No newline at end of file