From e7f04498945e1ccea1b646d058583ecaa143490d Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Fri, 8 Jul 2022 17:13:03 -0300 Subject: [PATCH 01/15] Created using Colaboratory --- Desafio_01_Fernando_Krum_DS38.ipynb | 154 ++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Desafio_01_Fernando_Krum_DS38.ipynb diff --git a/Desafio_01_Fernando_Krum_DS38.ipynb b/Desafio_01_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..e4528ec --- /dev/null +++ b/Desafio_01_Fernando_Krum_DS38.ipynb @@ -0,0 +1,154 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "SbLLE9q1eldC" + }, + "source": [ + "### Desafio 1\n", + "\n", + "Escreva um programa em Python para contabilizar a quantidade de ocorrências de cada palavra." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "WhtbdwFseldD" + }, + "outputs": [], + "source": [ + "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" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "M58o1U9KfAxa" + }, + "outputs": [], + "source": [ + "qtdadeTotal = len(palavras)" + ] + }, + { + "cell_type": "code", + "source": [ + "#modelo para contagem de palavras:\n", + "palavras.count('red')" + ], + "metadata": { + "id": "CWEFRp2Bacqe", + "outputId": "5775650d-d856-4fc4-802c-44f5abb9a698", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "4" + ] + }, + "metadata": {}, + "execution_count": 6 + } + ] + }, + { + "cell_type": "code", + "source": [ + "contagemPalavras = {} #inicia dicionario para armazenar contagem de palavras\n", + "for palavra in palavras:\n", + " contagemPalavras[palavra] = palavras.count(palavra)\n" + ], + "metadata": { + "id": "06kpQDxRawSC" + }, + "execution_count": 9, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "contagemPalavras" + ], + "metadata": { + "id": "gQ8P2xvIcN90", + "outputId": "89453f9a-d92e-45cf-fcc8-33879d663a30", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{'black': 5,\n", + " 'eyes': 1,\n", + " 'green': 4,\n", + " 'orange': 4,\n", + " 'pink': 6,\n", + " 'red': 4,\n", + " 'white': 5}" + ] + }, + "metadata": {}, + "execution_count": 10 + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 1.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 796d36463fca1067fbfb04913a4968e4fd5a0287 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Fri, 8 Jul 2022 17:15:04 -0300 Subject: [PATCH 02/15] Created using Colaboratory --- Desafio_02_Fernando_Krum_DS38.ipynb | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Desafio_02_Fernando_Krum_DS38.ipynb diff --git a/Desafio_02_Fernando_Krum_DS38.ipynb b/Desafio_02_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..492c705 --- /dev/null +++ b/Desafio_02_Fernando_Krum_DS38.ipynb @@ -0,0 +1,81 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "A1DyFQAkcivd" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "q1NCks7Af6JN" + }, + "source": [ + "### Desafio 2\n", + "\n", + "Escreva uma função que receba um número inteiro de horas e converta esse número para segundos.\n", + "\n", + "Exemplo:\n", + "\n", + "convert(5) ➞ 18000\n", + "\n", + "convert(3) ➞ 10800\n", + "\n", + "convert(2) ➞ 7200" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "sSm6F7sff6JO" + }, + "outputs": [], + "source": [ + "def convert_to_sec(number):\n", + " return number * 60 * 60" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 2.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 5060065ab14ea0958e4f1e614563679640ab5431 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Fri, 8 Jul 2022 17:37:15 -0300 Subject: [PATCH 03/15] Created using Colaboratory --- Desafio_03_Fernando_Krum_DS38.ipynb | 132 ++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 Desafio_03_Fernando_Krum_DS38.ipynb diff --git a/Desafio_03_Fernando_Krum_DS38.ipynb b/Desafio_03_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..6a8d6cc --- /dev/null +++ b/Desafio_03_Fernando_Krum_DS38.ipynb @@ -0,0 +1,132 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "9apVxxygf6JR" + }, + "source": [ + "### Desafio 3\n", + "\n", + "Escreva uma função que receba uma lista como entrada e retorne uma nova lista ordenada e sem valores duplicados.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "id": "ndTkQEUBf6JS" + }, + "outputs": [], + "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" + ] + }, + { + "cell_type": "code", + "source": [ + "lista.sort()\n", + "lista" + ], + "metadata": { + "id": "y-Gazedrd2xD", + "outputId": "437c9f0b-bf8f-4eae-9d0a-d752ffa38366", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 31, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 9, 13, 15, 30, 45]" + ] + }, + "metadata": {}, + "execution_count": 31 + } + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "id": "wo2rA-NriFtO" + }, + "outputs": [], + "source": [ + "def NovaLista(lista):\n", + " lista_nova = []\n", + " for i in lista:\n", + " if not(i in lista_nova):\n", + " lista_nova.append(i)\n", + "\n", + " print(lista_nova)" + ] + }, + { + "cell_type": "code", + "source": [ + "NovaLista(lista)" + ], + "metadata": { + "id": "OmY2A_iLfeGs", + "outputId": "1494fea5-1222-4928-d246-ca339714a023", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 37, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]\n" + ] + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 3.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 584c10b28943b286497012dd4991d15d94e98620 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Fri, 8 Jul 2022 18:20:14 -0300 Subject: [PATCH 04/15] Created using Colaboratory --- Desafio_04_Fernando_Krum_DS38.ipynb | 105 ++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Desafio_04_Fernando_Krum_DS38.ipynb diff --git a/Desafio_04_Fernando_Krum_DS38.ipynb b/Desafio_04_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..bab3749 --- /dev/null +++ b/Desafio_04_Fernando_Krum_DS38.ipynb @@ -0,0 +1,105 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "dOqcKUYZf6JW" + }, + "source": [ + "### Desafio 4\n", + "\n", + "Escreva uma função cuja entrada é uma string e a saída é outra string com as palavras em ordem inversa.\n", + "\n", + "Exemplo:\n", + "\n", + "inverte_texto(\"Python é legal\") ➞ \"legal é Python\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "I5TInJDaf6JW" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "source": [ + "def inverte_texto(stringTexto):\n", + " stringTexto = stringTexto.split()\n", + " strintTexto = stringTexto.reverse()\n", + " stringTexto = ' '.join(stringTexto)\n", + " return print(stringTexto)\n" + ], + "metadata": { + "id": "s6vww8hvnPKJ" + }, + "execution_count": 42, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "inverte_texto('Python é muito legal mesmo')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "hB-SmVozrd0_", + "outputId": "c8bb128e-a556-477c-e09c-79f97ed879dd" + }, + "execution_count": 44, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "mesmo legal muito é Python\n" + ] + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 4.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 7301240b3cb3d58864d4505dd583f870bf67418a Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 00:07:58 -0300 Subject: [PATCH 05/15] Created using Colaboratory --- Desafio_05_Fernando_Krum_DS38.ipynb | 163 ++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Desafio_05_Fernando_Krum_DS38.ipynb diff --git a/Desafio_05_Fernando_Krum_DS38.ipynb b/Desafio_05_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..1368a6a --- /dev/null +++ b/Desafio_05_Fernando_Krum_DS38.ipynb @@ -0,0 +1,163 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gQbaWOWcW1g_" + }, + "source": [ + "# Desafio 5\n", + "Você trabalha em uma loja de sapatos e deve contatar uma série de clientes. Seus números de telefone estão na lista abaixo. No entanto, é possível notar números duplicados na lista dada. Você seria capaz de remover estes duplicados para evitar que clientes sejam contatados mais de uma vez?" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "T68FjcUmWear" + }, + "outputs": [], + "source": [ + "numeros_telefone = [\n", + "'(765) 368-1506',\n", + "'(285) 608-2448',\n", + "'(255) 826-9050',\n", + "'(554) 994-1517',\n", + "'(285) 608-2448',\n", + "'(596) 336-5508',\n", + "'(511) 821-7870',\n", + "'(410) 665-4447',\n", + "'(821) 642-8987',\n", + "'(285) 608-2448',\n", + "'(311) 799-3883',\n", + "'(935) 875-2054',\n", + "'(464) 788-2397',\n", + "'(765) 368-1506',\n", + "'(650) 684-1437',\n", + "'(812) 816-0881',\n", + "'(285) 608-2448',\n", + "'(885) 407-1719',\n", + "'(943) 769-1061',\n", + "'(596) 336-5508',\n", + "'(765) 368-1506',\n", + "'(255) 826-9050',\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "F8n1sN-4XrW3", + "outputId": "58e14a4c-5517-40a7-933e-0d52488c3b12" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "15" + ] + }, + "metadata": {}, + "execution_count": 7 + } + ], + "source": [ + "#para obter somente elementos únicos, podemos usar a função \"set\" para armazenar o conteúdo.\n", + "#os sets são desordenados, não permitem repetição de elementos. Um set pode conter elementos de diferentes tipos (arrays, listas, booleanos, etc.)\n", + "len(set(numeros_telefone))" + ] + }, + { + "cell_type": "code", + "source": [ + "elementosUnicos = set(numeros_telefone)" + ], + "metadata": { + "id": "y4nyaGfrCdf7" + }, + "execution_count": 10, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "elementosUnicos" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_BtbQBaqCoBu", + "outputId": "6a5ac484-da4c-49ca-f014-c97dffa2aca9" + }, + "execution_count": 11, + "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": {}, + "execution_count": 11 + } + ] + } + ], + "metadata": { + "colab": { + "name": "Desafio 5.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 419b112cc6fefc25a148ab6d626480a13f22e9d7 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 00:22:33 -0300 Subject: [PATCH 06/15] Created using Colaboratory --- Desafio_06_Fernando_Krum_DS38.ipynb | 176 ++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 Desafio_06_Fernando_Krum_DS38.ipynb diff --git a/Desafio_06_Fernando_Krum_DS38.ipynb b/Desafio_06_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..f17c6f7 --- /dev/null +++ b/Desafio_06_Fernando_Krum_DS38.ipynb @@ -0,0 +1,176 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "AiI1_KNTf6Jh" + }, + "source": [ + "### Desafio 6\n", + "\n", + "Crie uma função que receba duas listas e retorne uma lista que contenha apenas os elementos comuns entre as listas (sem repetição). A função deve suportar lista de tamanhos diferentes.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "skbgaNijFSZS" + }, + "source": [ + "**Listas**" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "hO9iKYADFSZT" + }, + "outputs": [], + "source": [ + "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]" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "mvxpy_vCf6Jh" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "ly-N_Aq624RQ" + }, + "outputs": [], + "source": [ + "resultadoComum = []\n", + "for i in a:\n", + " if i in b:\n", + " resultadoComum.append(i)" + ] + }, + { + "cell_type": "code", + "source": [ + "set(resultadoComum)" + ], + "metadata": { + "id": "2TBjtVynGKc1", + "outputId": "eeabd012-0335-4dd4-dd9c-86d632987747", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "{1, 2, 3, 5, 8, 13}" + ] + }, + "metadata": {}, + "execution_count": 6 + } + ] + }, + { + "cell_type": "code", + "source": [ + "def elementos_comuns(lista1, lista2):\n", + " set1 = set(lista1)\n", + " set2 = set(lista2)\n", + " final = list(set1.intersection(set2))\n", + " return final" + ], + "metadata": { + "id": "WFEbMPHhHdBb" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "elementos_comuns(a, b)" + ], + "metadata": { + "id": "2R3EOrW6GTnu", + "outputId": "4831da29-0605-4dbf-8e28-4335c10631c0", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 8, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 5, 8, 13]" + ] + }, + "metadata": {}, + "execution_count": 8 + } + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "KeoiopLTILOG" + }, + "execution_count": null, + "outputs": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 6.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 99d95558219f7476c44181cca8c56ebec00be42f Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 11:37:28 -0300 Subject: [PATCH 07/15] Created using Colaboratory --- Desafio_06_Fernando_Krum_DS38.ipynb | 57 +++++------------------------ 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/Desafio_06_Fernando_Krum_DS38.ipynb b/Desafio_06_Fernando_Krum_DS38.ipynb index f17c6f7..aaafae1 100644 --- a/Desafio_06_Fernando_Krum_DS38.ipynb +++ b/Desafio_06_Fernando_Krum_DS38.ipynb @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": { "id": "hO9iKYADFSZT" }, @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": { "id": "mvxpy_vCf6Jh" }, @@ -53,59 +53,20 @@ "# Seu código" ] }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "id": "ly-N_Aq624RQ" - }, - "outputs": [], - "source": [ - "resultadoComum = []\n", - "for i in a:\n", - " if i in b:\n", - " resultadoComum.append(i)" - ] - }, - { - "cell_type": "code", - "source": [ - "set(resultadoComum)" - ], - "metadata": { - "id": "2TBjtVynGKc1", - "outputId": "eeabd012-0335-4dd4-dd9c-86d632987747", - "colab": { - "base_uri": "https://localhost:8080/" - } - }, - "execution_count": 6, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "{1, 2, 3, 5, 8, 13}" - ] - }, - "metadata": {}, - "execution_count": 6 - } - ] - }, { "cell_type": "code", "source": [ "def elementos_comuns(lista1, lista2):\n", " set1 = set(lista1)\n", " set2 = set(lista2)\n", + " #é possível usar o método \"intersection\" para trazer elementos comuns a dois ou mais sets\n", " final = list(set1.intersection(set2))\n", " return final" ], "metadata": { "id": "WFEbMPHhHdBb" }, - "execution_count": 7, + "execution_count": 6, "outputs": [] }, { @@ -114,13 +75,13 @@ "elementos_comuns(a, b)" ], "metadata": { - "id": "2R3EOrW6GTnu", - "outputId": "4831da29-0605-4dbf-8e28-4335c10631c0", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "2R3EOrW6GTnu", + "outputId": "e21d3f11-81b0-4d58-c314-979e5ba34b6f" }, - "execution_count": 8, + "execution_count": 7, "outputs": [ { "output_type": "execute_result", @@ -130,7 +91,7 @@ ] }, "metadata": {}, - "execution_count": 8 + "execution_count": 7 } ] }, From b3453eef0357ff7bb61814bc77b6671b8dbda2b8 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 12:24:22 -0300 Subject: [PATCH 08/15] Created using Colaboratory --- Desafio_07_Fernando_Krum_DS38.ipynb | 214 ++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 Desafio_07_Fernando_Krum_DS38.ipynb diff --git a/Desafio_07_Fernando_Krum_DS38.ipynb b/Desafio_07_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..f9454ab --- /dev/null +++ b/Desafio_07_Fernando_Krum_DS38.ipynb @@ -0,0 +1,214 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "gQbaWOWcW1g_" + }, + "source": [ + "# Desafio 7\n", + "Um professor de universidade tem uma turma com os seguintes números de telefones:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "T68FjcUmWear" + }, + "outputs": [], + "source": [ + "telefones_alunos = ['(873) 810-8267', '(633) 244-7325', '(300) 303-5462', \n", + " '(938) 300-8890', '(429) 264-7427', '(737) 805-2326', \n", + " '(768) 956-8497', '(941) 225-3869', '(203) 606-9463', \n", + " '(294) 430-7720', '(896) 781-5087', '(397) 845-8267', \n", + " '(788) 717-6858', '(419) 734-4188', '(682) 595-3278', \n", + " '(835) 955-1498', '(296) 415-9944', '(897) 932-2512', \n", + " '(263) 415-3893', '(822) 640-8496', '(640) 427-2597', \n", + " '(856) 338-7094', '(807) 554-4076', '(641) 367-5279', \n", + " '(828) 866-0696', '(727) 376-5749', '(921) 948-2244', \n", + " '(964) 710-9625', '(596) 685-1242', '(403) 343-7705', \n", + " '(227) 389-3685', '(264) 372-7298', '(797) 649-3653', \n", + " '(374) 361-3844', '(618) 490-4228', '(987) 803-5550', \n", + " '(228) 976-9699', '(757) 450-9985', '(491) 666-5367',\n", + " ]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ryYrStScXgZ3" + }, + "source": [ + "Ele criou um grupo do WhatsApp. No entanto, somente os seguintes números entraram no grupo." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "0Hxk13ciXZ3h" + }, + "outputs": [], + "source": [ + "entraram_no_grupo = ['(596) 685-1242', '(727) 376-5749', '(987) 803-5550', \n", + " '(633) 244-7325', '(828) 866-0696', '(263) 415-3893', \n", + " '(203) 606-9463', '(296) 415-9944', '(419) 734-4188', \n", + " '(618) 490-4228', '(682) 595-3278', '(938) 300-8890', \n", + " '(264) 372-7298', '(768) 956-8497', '(737) 805-2326', \n", + " '(788) 717-6858', '(228) 976-9699', '(896) 781-5087',\n", + " '(374) 361-3844', '(921) 948-2244', '(807) 554-4076', \n", + " '(822) 640-8496', '(227) 389-3685', '(429) 264-7427', \n", + " '(397) 845-8267']" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-inLXlaxoWnC" + }, + "source": [ + "Você seria capaz de criar uma lista dos alunos que ainda não entraram no grupo para que sejam contatados individualmente?" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_OSrDQ1noh62", + "outputId": "5feb4ee1-6eb6-449c-e4be-74bc70793cc9" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "39" + ] + }, + "metadata": {}, + "execution_count": 3 + } + ], + "source": [ + "#Seu código.\n", + "#vamos fazer uma subtração entre a lista tota e a lista de quem entrou no grupo\n", + "len(telefones_alunos)" + ] + }, + { + "cell_type": "code", + "source": [ + "len(entraram_no_grupo)" + ], + "metadata": { + "id": "2sCt1zNQscZD", + "outputId": "a6207d7e-67a9-4a37-e23e-fa5dd1bfa0b8", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "25" + ] + }, + "metadata": {}, + "execution_count": 5 + } + ] + }, + { + "cell_type": "code", + "source": [ + "set_telefones_alunos = set(telefones_alunos)\n", + "set_entraram_no_grupo = set(entraram_no_grupo)" + ], + "metadata": { + "id": "5HWosJeVsnxo" + }, + "execution_count": 9, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "contatar_individualmente = set_telefones_alunos.difference(set_entraram_no_grupo)" + ], + "metadata": { + "id": "JXyROx5jsvgS" + }, + "execution_count": 10, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "len(contatar_individualmente)" + ], + "metadata": { + "id": "497q9VigtV_y", + "outputId": "1a4a9f05-06e1-4fd7-b6a3-2ba4f3aa9de1", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 12, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "14" + ] + }, + "metadata": {}, + "execution_count": 12 + } + ] + } + ], + "metadata": { + "colab": { + "name": "Desafio 7.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 21ab2ae1fefcfafaaa81367a42ad84c7171e3317 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 21:49:56 -0300 Subject: [PATCH 09/15] Created using Colaboratory --- Desafio_08_Fernando_Krum_DS38.ipynb | 212 ++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 Desafio_08_Fernando_Krum_DS38.ipynb diff --git a/Desafio_08_Fernando_Krum_DS38.ipynb b/Desafio_08_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..d195e3a --- /dev/null +++ b/Desafio_08_Fernando_Krum_DS38.ipynb @@ -0,0 +1,212 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "o3tkeMDNf6Jo" + }, + "source": [ + "### Desafio 8\n", + "\n", + "Escreva um script Python para encontrar as 10 palavras mais longas em um arquivo de texto.\n", + "O arquivo .txt está localizado na mesma pasta do projeto (**texto.txt**)." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "EknxjSG0f6Jo" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "source": [ + "#ao inves de fazer upload do arquivo, vamos usálo direto do endereco do github, usando a biblioteca requests\n", + "url = 'https://raw.githubusercontent.com/ferkrum/DS-Notebooks-br-python-challenges/master/texto.txt'" + ], + "metadata": { + "id": "CMflrIicldpp" + }, + "execution_count": 64, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "import requests" + ], + "metadata": { + "id": "KTByewpcpwJZ" + }, + "execution_count": 65, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "texto = requests.get(url)" + ], + "metadata": { + "id": "l0qdwrlwpxzV" + }, + "execution_count": 66, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "type(texto)" + ], + "metadata": { + "id": "HHpV-KeQrAYJ", + "outputId": "6ee23fe0-48c2-430f-fa78-59c3abf7fcde", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 67, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "requests.models.Response" + ] + }, + "metadata": {}, + "execution_count": 67 + } + ] + }, + { + "cell_type": "code", + "source": [ + "listaTexto = texto.content.decode('utf-8').replace('\\n', '').replace(',', '').replace(')', '').replace('(', '').replace('.', '').replace('?', '').replace('\\r', '').strip().split()" + ], + "metadata": { + "id": "Y52H_dQjp3mD" + }, + "execution_count": 69, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "len(listaTexto)" + ], + "metadata": { + "id": "CgwIb012sUrY", + "outputId": "fbe60d38-83da-4d49-f9d4-48286cd5c692", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 70, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "99" + ] + }, + "metadata": {}, + "execution_count": 70 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#É possível sortear uma lista usando uma função como argumento de sort (que não seja unicamente a ordem alfabética do elemento).\n", + "#https://www.w3schools.com/python/ref_list_sort.asp\n", + "def tamanho(e):\n", + " return len(e)\n", + "\n", + "listaTexto.sort(reverse=True, key = tamanho)" + ], + "metadata": { + "id": "J1ZJ--EetgKo" + }, + "execution_count": 76, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "listaTexto[:10]" + ], + "metadata": { + "id": "htPYAEuEuVTt", + "outputId": "bc66c663-36f0-4928-b372-7d95bab9d57c", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 78, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "['general-purpose',\n", + " 'object-oriented',\n", + " 'comprehensive',\n", + " 'intermediate',\n", + " 'interpreted',\n", + " 'programming',\n", + " 'languageIts',\n", + " 'readability',\n", + " 'programmers',\n", + " 'programming']" + ] + }, + "metadata": {}, + "execution_count": 78 + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 8.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 8b72d00b84b4d2c7b3bceafca9294ec74f2a0dc8 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 22:11:19 -0300 Subject: [PATCH 10/15] Created using Colaboratory --- Desafio_09_Fernando_Krum_DS38.ipynb | 134 ++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Desafio_09_Fernando_Krum_DS38.ipynb diff --git a/Desafio_09_Fernando_Krum_DS38.ipynb b/Desafio_09_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..5c25840 --- /dev/null +++ b/Desafio_09_Fernando_Krum_DS38.ipynb @@ -0,0 +1,134 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "HpvTpUBGf6Jr" + }, + "source": [ + "### Desafio 9\n", + "\n", + "Escreva uma função que retorne a soma dos múltiplos de 3 e 5 entre 0 e um número limite, que vai ser utilizado como parâmetro. \\\n", + "Por exemplo, se o limite for 20, ele retornará a soma de 3, 5, 6, 9, 10, 12, 15, 18, 20." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "195C6bw-f6Js" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "id": "a_6aqcKp6wrN" + }, + "outputs": [], + "source": [ + "def funcao(limite):\n", + " multiplos = []\n", + " soma = 0\n", + " for i in range(limite + 1):\n", + " #print(i)\n", + " if (i % 3) == 0 or (i % 5) == 0:\n", + " multiplos.append(i)\n", + " soma = soma + i\n", + " print('lista de múltiplos:', multiplos)\n", + " print('soma: ',soma)\n" + ] + }, + { + "cell_type": "code", + "source": [ + "funcao(20)" + ], + "metadata": { + "id": "Pz9ddt2qvekA", + "outputId": "29752ab0-004f-4de8-b9f5-7f1b4ca0ba82", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 34, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "lista de múltiplos: [0, 3, 5, 6, 9, 10, 12, 15, 18, 20]\n", + "soma: 98\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "oiEj2pniviyN", + "outputId": "878816c0-1813-46a8-c1d8-1f56007cf566", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 21, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "0" + ] + }, + "metadata": {}, + "execution_count": 21 + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 9.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From b13c5cf16cd4da7b21a935721bd3ea0f69dfbeee Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 22:44:43 -0300 Subject: [PATCH 11/15] Created using Colaboratory --- Desafio_10_Fernando_Krum_DS38.ipynb | 168 ++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Desafio_10_Fernando_Krum_DS38.ipynb diff --git a/Desafio_10_Fernando_Krum_DS38.ipynb b/Desafio_10_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..82d5ae5 --- /dev/null +++ b/Desafio_10_Fernando_Krum_DS38.ipynb @@ -0,0 +1,168 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "a4-FLDRof6Jv" + }, + "source": [ + "### Desafio 10\n", + "\n", + "Dada uma lista, divida-a em 3 partes iguais e reverta a ordem de cada lista.\n", + "\n", + "**Exemplo:** \n", + "\n", + "Entrada: \\\n", + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n", + "\n", + "Saída: \\\n", + "Parte 1 [8, 45, 11] \\\n", + "Parte 2 [12, 14, 23] \\\n", + "Parte 3 [89, 45, 78] " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "IJ70pUjnf6Jw" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "id": "pNrXNVqf8Wc1" + }, + "outputs": [], + "source": [ + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89, 99, 100, 101]" + ] + }, + { + "cell_type": "code", + "source": [ + "lista=[1,2,3]" + ], + "metadata": { + "id": "tG5QTZY_1t6W" + }, + "execution_count": 43, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "len(sampleList)" + ], + "metadata": { + "id": "gEefROR80Slp", + "outputId": "42592c1f-a978-411a-800f-c1179553ad90", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "9" + ] + }, + "metadata": {}, + "execution_count": 3 + } + ] + }, + { + "cell_type": "code", + "source": [ + "def funcaoLista(lista):\n", + " tamanho = len(lista)\n", + " if (tamanho % 3) == 0:\n", + " qElem = int(tamanho / 3)\n", + " parte1 = lista[0 : qElem]\n", + " parte2 = lista[(qElem) : qElem * 2]\n", + " parte3 = lista[(qElem *2) : qElem * 3] \n", + " print(parte1)\n", + " print(parte2)\n", + " print(parte3)\n", + " else:\n", + " print('A lista não pode ser dividida em 3 partes iguais.')" + ], + "metadata": { + "id": "OJS9-VhB0api" + }, + "execution_count": 45, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "funcaoLista(sampleList)" + ], + "metadata": { + "id": "pqhVh_WA1pFm", + "outputId": "a959f964-c0f5-4f5d-b299-e8306af14e1c", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 46, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[11, 45, 8, 23]\n", + "[14, 12, 78, 45]\n", + "[89, 99, 100, 101]\n" + ] + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 10.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From f0061baf6c29b3ba6811d351b5e29c9b0998f128 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 22:47:43 -0300 Subject: [PATCH 12/15] Delete Desafio_10_Fernando_Krum_DS38.ipynb --- Desafio_10_Fernando_Krum_DS38.ipynb | 168 ---------------------------- 1 file changed, 168 deletions(-) delete mode 100644 Desafio_10_Fernando_Krum_DS38.ipynb diff --git a/Desafio_10_Fernando_Krum_DS38.ipynb b/Desafio_10_Fernando_Krum_DS38.ipynb deleted file mode 100644 index 82d5ae5..0000000 --- a/Desafio_10_Fernando_Krum_DS38.ipynb +++ /dev/null @@ -1,168 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "a4-FLDRof6Jv" - }, - "source": [ - "### Desafio 10\n", - "\n", - "Dada uma lista, divida-a em 3 partes iguais e reverta a ordem de cada lista.\n", - "\n", - "**Exemplo:** \n", - "\n", - "Entrada: \\\n", - "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n", - "\n", - "Saída: \\\n", - "Parte 1 [8, 45, 11] \\\n", - "Parte 2 [12, 14, 23] \\\n", - "Parte 3 [89, 45, 78] " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "IJ70pUjnf6Jw" - }, - "outputs": [], - "source": [ - "# Seu código" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": { - "id": "pNrXNVqf8Wc1" - }, - "outputs": [], - "source": [ - "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89, 99, 100, 101]" - ] - }, - { - "cell_type": "code", - "source": [ - "lista=[1,2,3]" - ], - "metadata": { - "id": "tG5QTZY_1t6W" - }, - "execution_count": 43, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "len(sampleList)" - ], - "metadata": { - "id": "gEefROR80Slp", - "outputId": "42592c1f-a978-411a-800f-c1179553ad90", - "colab": { - "base_uri": "https://localhost:8080/" - } - }, - "execution_count": 3, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "9" - ] - }, - "metadata": {}, - "execution_count": 3 - } - ] - }, - { - "cell_type": "code", - "source": [ - "def funcaoLista(lista):\n", - " tamanho = len(lista)\n", - " if (tamanho % 3) == 0:\n", - " qElem = int(tamanho / 3)\n", - " parte1 = lista[0 : qElem]\n", - " parte2 = lista[(qElem) : qElem * 2]\n", - " parte3 = lista[(qElem *2) : qElem * 3] \n", - " print(parte1)\n", - " print(parte2)\n", - " print(parte3)\n", - " else:\n", - " print('A lista não pode ser dividida em 3 partes iguais.')" - ], - "metadata": { - "id": "OJS9-VhB0api" - }, - "execution_count": 45, - "outputs": [] - }, - { - "cell_type": "code", - "source": [ - "funcaoLista(sampleList)" - ], - "metadata": { - "id": "pqhVh_WA1pFm", - "outputId": "a959f964-c0f5-4f5d-b299-e8306af14e1c", - "colab": { - "base_uri": "https://localhost:8080/" - } - }, - "execution_count": 46, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "[11, 45, 8, 23]\n", - "[14, 12, 78, 45]\n", - "[89, 99, 100, 101]\n" - ] - } - ] - } - ], - "metadata": { - "anaconda-cloud": {}, - "colab": { - "name": "Desafio 10.ipynb", - "provenance": [], - "include_colab_link": true - }, - "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.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file From 8cbf7e43c30a841de8830b0428fddbe69a13df60 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 22:48:05 -0300 Subject: [PATCH 13/15] Created using Colaboratory --- Desafio_10_Fernando_Krum_DS38.ipynb | 171 ++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Desafio_10_Fernando_Krum_DS38.ipynb diff --git a/Desafio_10_Fernando_Krum_DS38.ipynb b/Desafio_10_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..05c1afa --- /dev/null +++ b/Desafio_10_Fernando_Krum_DS38.ipynb @@ -0,0 +1,171 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "a4-FLDRof6Jv" + }, + "source": [ + "### Desafio 10\n", + "\n", + "Dada uma lista, divida-a em 3 partes iguais e reverta a ordem de cada lista.\n", + "\n", + "**Exemplo:** \n", + "\n", + "Entrada: \\\n", + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n", + "\n", + "Saída: \\\n", + "Parte 1 [8, 45, 11] \\\n", + "Parte 2 [12, 14, 23] \\\n", + "Parte 3 [89, 45, 78] " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "IJ70pUjnf6Jw" + }, + "outputs": [], + "source": [ + "# Seu código" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "id": "pNrXNVqf8Wc1" + }, + "outputs": [], + "source": [ + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89, 99, 100, 101]" + ] + }, + { + "cell_type": "code", + "source": [ + "lista=[1,2,3]" + ], + "metadata": { + "id": "tG5QTZY_1t6W" + }, + "execution_count": 43, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "len(sampleList)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "gEefROR80Slp", + "outputId": "42592c1f-a978-411a-800f-c1179553ad90" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "9" + ] + }, + "metadata": {}, + "execution_count": 3 + } + ] + }, + { + "cell_type": "code", + "source": [ + "def funcaoLista(lista):\n", + " tamanho = len(lista)\n", + " if (tamanho % 3) == 0:\n", + " qElem = int(tamanho / 3)\n", + " parte1 = lista[0 : qElem]\n", + " parte2 = lista[(qElem) : qElem * 2]\n", + " parte3 = lista[(qElem *2) : qElem * 3] \n", + " parte1.reverse()\n", + " parte2.reverse()\n", + " parte3.reverse()\n", + " print(parte1)\n", + " print(parte2)\n", + " print(parte3)\n", + " else:\n", + " print('A lista não pode ser dividida em 3 partes iguais.')" + ], + "metadata": { + "id": "OJS9-VhB0api" + }, + "execution_count": 55, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "funcaoLista(sampleList)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pqhVh_WA1pFm", + "outputId": "4cc6d496-5db9-4575-936e-03d5175e88c7" + }, + "execution_count": 56, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[23, 8, 45, 11]\n", + "[45, 78, 12, 14]\n", + "[101, 100, 99, 89]\n" + ] + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 10.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From a8aa96a7bd1c9277ed48a0f59af0d68d6da6982a Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 23:04:40 -0300 Subject: [PATCH 14/15] Created using Colaboratory --- Desafio_11_Fernando_Krum_DS38.ipynb | 115 ++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Desafio_11_Fernando_Krum_DS38.ipynb diff --git a/Desafio_11_Fernando_Krum_DS38.ipynb b/Desafio_11_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..041a66e --- /dev/null +++ b/Desafio_11_Fernando_Krum_DS38.ipynb @@ -0,0 +1,115 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "y1R0m4oWf6Jz" + }, + "source": [ + "### Desafio 8\n", + "Dados uma sequência com `n` números inteiros, determinar quantos números da sequência são pares e quantos são ímpares.\\\n", + "Por exemplo, para a sequência\n", + "\n", + "`6 2 7 -5 8 -4`\n", + "\n", + "a sua função deve retornar o número 4 para o número de pares e 2 para o de ímpares.\\\n", + "A saída deve ser um **tupla** contendo primeiramente o número de pares e em seguida o número de ímpares.\\\n", + "Para o exemplo anterior, a saída seria `(4, 2)`." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "pSIzX4zUf6Jz" + }, + "outputs": [], + "source": [ + "# Seu código\n", + "lista = [6, 2, 7, -5, 8, -4]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "OQG6erslSjri" + }, + "outputs": [], + "source": [ + "def parImpar(lista):\n", + " contaPar = 0 \n", + " contaImpar = 0\n", + " for i in lista:\n", + " if (i % 2) == 0:\n", + " contaPar+=1\n", + " else:\n", + " contaImpar+=1\n", + " return (contaPar, contaImpar)\n" + ] + }, + { + "cell_type": "code", + "source": [ + "parImpar(lista)" + ], + "metadata": { + "id": "3IvIcSY-_0jB", + "outputId": "a2b92307-51d1-4c85-dea9-61e8ee9cf3a4", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 9, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(4, 2)" + ] + }, + "metadata": {}, + "execution_count": 9 + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 11.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 238b972caf7491c64749be74df1d757c78062932 Mon Sep 17 00:00:00 2001 From: Fernando Krum Date: Sun, 10 Jul 2022 23:48:35 -0300 Subject: [PATCH 15/15] Created using Colaboratory --- Desafio_12_Fernando_Krum_DS38.ipynb | 185 ++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 Desafio_12_Fernando_Krum_DS38.ipynb diff --git a/Desafio_12_Fernando_Krum_DS38.ipynb b/Desafio_12_Fernando_Krum_DS38.ipynb new file mode 100644 index 0000000..7911b5a --- /dev/null +++ b/Desafio_12_Fernando_Krum_DS38.ipynb @@ -0,0 +1,185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "AYHY2YXQf6J2" + }, + "source": [ + "### Desafio 12\n", + "\n", + "Escreva uma função em Python para verificar a validade de uma senha.\n", + "\n", + "A senha deve ter:\n", + "\n", + "* Pelo menos 1 letra entre [a-z] e 1 letra entre [A-Z].\n", + "* Pelo menos 1 número entre [0-9].\n", + "* Pelo menos 1 caractere de [$ # @].\n", + "* Comprimento mínimo de 6 caracteres.\n", + "* Comprimento máximo de 16 caracteres.\n", + "\n", + "Entradas: \"12345678\", \"J3sus0\", \"#Te5t300\", \"J*90j12374\", \"Michheeul\", \"Monk3y6\"\n", + "\n", + "A saída deve ser a senha e um texto indicando se a senha é válida ou inválida:\n", + "\n", + "```\n", + "\"1234\" - Senha inválida\n", + "\"Qw#1234\" - Senha válida\n", + "```" + ] + }, + { + "cell_type": "code", + "source": [ + "texto = 'fernando'" + ], + "metadata": { + "id": "wnFRu_2oCuiW" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "'f' in texto" + ], + "metadata": { + "id": "NBtG1ptFERDO", + "outputId": "6324326d-80c7-4ef1-edab-315266d94d81", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 24, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "True" + ] + }, + "metadata": {}, + "execution_count": 24 + } + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": { + "id": "UGgtGYGGf6J3" + }, + "outputs": [], + "source": [ + "# Seu código\n", + "#para checar as senhas vamos obter os valores ASCII das entradas das\n", + "#letras em minúsculo, em maiúsculo, os números 0-9 e os caracteres especiais.\n", + "#A função ord() devolve o valor ascii\n", + "#A função chr() faz o contrário\n", + "#a-z = 97 a 123\n", + "#A-Z = 65 a 90\n", + "#0-9 = 48 a 57\n", + "#$ = 36, # = 35, @ = 64\n", + "\n", + "def validaSenha(senha):\n", + " testeTamanho = False\n", + " testeMinusculo = False\n", + " testeMaiusculo = False\n", + " testeNumeros = False\n", + " testeCaractEsp = False\n", + " if (len(senha)>=6) and (len(senha)<=16):\n", + " testeTamanho = True\n", + " for i in senha:\n", + " if (ord(i) >= 97) and (ord(i) <= 123):\n", + " testeMinusculo = True\n", + " if (ord(i) >= 65) and (ord(i) <= 90):\n", + " testeMaiusculo = True\n", + " if (ord(i) >= 48) and (ord(i) <= 57):\n", + " testeNumeros = True\n", + " if (ord(i) == 36) or (ord(i) == 35) or (ord(i) == 64):\n", + " testeCaractEsp = True\n", + " \n", + " \n", + " print('testeTamanho:', testeTamanho)\n", + " print('testeMinusculo:', testeMinusculo)\n", + " print('testeMaiusculo:', testeMaiusculo)\n", + " print('testeNumeros:', testeNumeros)\n", + " print('testeCaractEsp:', testeCaractEsp)\n", + " \n", + " if (testeMinusculo and testeMaiusculo and testeNumeros and testeCaractEsp and testeTamanho):\n", + " print(senha)\n", + " print('Senha válida!')\n", + " else:\n", + " print('Senha inválida!')" + ] + }, + { + "cell_type": "code", + "source": [ + "validaSenha('akjkjMaaa9@')" + ], + "metadata": { + "id": "l-ogL4x5F2Ma", + "outputId": "e02e131d-ebf7-4da7-82f1-d3f18c356b3c", + "colab": { + "base_uri": "https://localhost:8080/" + } + }, + "execution_count": 58, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "testeTamanho: True\n", + "testeMinusculo: True\n", + "testeMaiusculo: True\n", + "testeNumeros: True\n", + "testeCaractEsp: True\n", + "akjkjMaaa9@\n", + "Senha válida!\n" + ] + } + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "name": "Desafio 12.ipynb", + "provenance": [], + "include_colab_link": true + }, + "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.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file