diff --git a/Desafio_01_haisa.ipynb b/Desafio_01_haisa.ipynb new file mode 100644 index 0000000..32d80cb --- /dev/null +++ b/Desafio_01_haisa.ipynb @@ -0,0 +1,96 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 5, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "WhtbdwFseldD" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Counter({'pink': 6, 'black': 5, 'white': 5, 'red': 4, 'green': 4, 'orange': 4, 'eyes': 1})\n" + ] + } + ], + "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", + "import collections\n", + "contar_palavras = collections.Counter(palavras)\n", + "\n", + "print(contar_palavras)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "M58o1U9KfAxa" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 1.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_02_haisa.ipynb b/Desafio_02_haisa.ipynb new file mode 100644 index 0000000..d3d8271 --- /dev/null +++ b/Desafio_02_haisa.ipynb @@ -0,0 +1,92 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 7, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "sSm6F7sff6JO" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "18000" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def convert_to_sec(number):\n", + " return number*3600\n", + "\n", + "convert_to_sec(5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 2.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_03_haisa.ipynb b/Desafio_03_haisa.ipynb new file mode 100644 index 0000000..02459c2 --- /dev/null +++ b/Desafio_03_haisa.ipynb @@ -0,0 +1,94 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 12, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "ndTkQEUBf6JS" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]\n" + ] + } + ], + "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\n", + "def organizar_lista(lista):\n", + " lista_unica = set(lista)\n", + " lista_ordenada = sorted(lista_unica)\n", + " return lista_ordenada\n", + "\n", + "print(organizar_lista(lista))\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "wo2rA-NriFtO" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 3.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_04_haisa.ipynb b/Desafio_04_haisa.ipynb new file mode 100644 index 0000000..1d4b99a --- /dev/null +++ b/Desafio_04_haisa.ipynb @@ -0,0 +1,96 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 8, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "I5TInJDaf6JW" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "legal é Python\n" + ] + } + ], + "source": [ + "# Seu código\n", + "frase = \"Python é legal\"\n", + "\n", + "def inverte_texto(str):\n", + " frase = str.split()\n", + " frase.reverse()\n", + " frase_inversa = \" \".join(frase)\n", + " return frase_inversa\n", + "\n", + "\n", + "frase_teste = inverte_texto(frase)\n", + "print(frase_teste)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 4.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_05_haisa.ipynb b/Desafio_05_haisa.ipynb new file mode 100644 index 0000000..3768e9e --- /dev/null +++ b/Desafio_05_haisa.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 1, + "metadata": { + "colab": {}, + "colab_type": "code", + "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": 3, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "F8n1sN-4XrW3" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['(410) 665-4447', '(812) 816-0881', '(311) 799-3883', '(821) 642-8987', '(511) 821-7870', '(285) 608-2448', '(464) 788-2397', '(943) 769-1061', '(650) 684-1437', '(255) 826-9050', '(935) 875-2054', '(885) 407-1719', '(554) 994-1517', '(596) 336-5508', '(765) 368-1506']\n" + ] + } + ], + "source": [ + "numeros_telefone_unicos = list(set(numeros_telefone))\n", + "\n", + "print(numeros_telefone_unicos)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyO0u4amKtoFgAgnb/IGUddy", + "include_colab_link": true, + "name": "Desafio 5.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_06_haisa.ipynb b/Desafio_06_haisa.ipynb new file mode 100644 index 0000000..900221c --- /dev/null +++ b/Desafio_06_haisa.ipynb @@ -0,0 +1,115 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": {}, + "source": [ + "**Listas**" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "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": 4, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "mvxpy_vCf6Jh" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 2, 3, 5, 8, 13]\n" + ] + } + ], + "source": [ + "def lista_comum(x,y):\n", + " lista_comum = list(set(x) & set(y))\n", + " return lista_comum\n", + "\n", + "lista_teste = lista_comum(a,b)\n", + "\n", + "print(lista_teste)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "ly-N_Aq624RQ" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 6.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_07_haisa.ipynb b/Desafio_07_haisa.ipynb new file mode 100644 index 0000000..3b51ab3 --- /dev/null +++ b/Desafio_07_haisa.ipynb @@ -0,0 +1,151 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": { + "colab": {}, + "colab_type": "code", + "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": { + "colab_type": "text", + "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": { + "colab": {}, + "colab_type": "code", + "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": { + "colab_type": "text", + "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": 6, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "_OSrDQ1noh62" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['(856) 338-7094', '(491) 666-5367', '(294) 430-7720', '(897) 932-2512', '(640) 427-2597', '(403) 343-7705', '(797) 649-3653', '(641) 367-5279', '(757) 450-9985', '(300) 303-5462', '(873) 810-8267', '(835) 955-1498', '(964) 710-9625', '(941) 225-3869']\n" + ] + } + ], + "source": [ + "#Seu código.\n", + "\n", + "nao_entraram_no_grupo = list(set(telefones_alunos) - set(entraram_no_grupo))\n", + "\n", + "print(nao_entraram_no_grupo)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyPinyzdF60Dyi+YfEQiCPfO", + "include_colab_link": true, + "name": "Desafio 7.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_08_haisa.ipynb b/Desafio_08_haisa.ipynb new file mode 100644 index 0000000..0568f76 --- /dev/null +++ b/Desafio_08_haisa.ipynb @@ -0,0 +1,96 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 19, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "EknxjSG0f6Jo" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['general-purpose,', 'object-oriented,', 'comprehensive', 'intermediate)', 'interpreted,', 'language.Its', 'readability,', 'high-level,', 'programming', 'programmers']\n" + ] + } + ], + "source": [ + "# Seu código\n", + "def dez_mais_longas(arquivo):\n", + " nome_arquivo = arquivo\n", + " palavras = (palavra for palavra in open(nome_arquivo).read().split())\n", + " palavras = sorted(palavras, key=len, reverse=True) \n", + " return list([palavra for palavra in palavras[:10]])\n", + "\n", + "texto_teste = \"texto.txt\"\n", + "lista_palavras = dez_mais_longas(texto_teste)\n", + "\n", + "print(lista_palavras)" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "ZYbqEWBG5nKx" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 8.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_09_haisa.ipynb b/Desafio_09_haisa.ipynb new file mode 100644 index 0000000..5182965 --- /dev/null +++ b/Desafio_09_haisa.ipynb @@ -0,0 +1,99 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 10, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "195C6bw-f6Js" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "98\n" + ] + } + ], + "source": [ + "# Seu código\n", + "\n", + "def soma_multiplos(limite):\n", + " soma = 0\n", + " for i in range(0,(limite+1)):\n", + " if not i % 5 or not i % 3:\n", + " soma = soma + i\n", + " return soma\n", + "\n", + "\n", + "\n", + "print(soma_multiplos(20))\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "a_6aqcKp6wrN" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 9.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_10_haisa.ipynb b/Desafio_10_haisa.ipynb new file mode 100644 index 0000000..3158e0d --- /dev/null +++ b/Desafio_10_haisa.ipynb @@ -0,0 +1,125 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 43, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "IJ70pUjnf6Jw" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "([8, 45, 11], [12, 14, 23], [89, 45, 78])\n" + ] + } + ], + "source": [ + "# Seu código\n", + "lista_teste = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n", + "\n", + "def cortar_lista(lista, cortes=3):\n", + " comprimento = len(lista)\n", + " listas = [lista[i*comprimento // cortes: (i+1)*comprimento // cortes] for i in range(cortes)]\n", + " lista_a = listas[0][::-1]\n", + " lista_b = listas[1][::-1]\n", + " lista_c = listas[2][::-1]\n", + " \n", + " return lista_a, lista_b, lista_c\n", + "\n", + "print(cortar_lista(lista_teste,3))\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "pNrXNVqf8Wc1" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 10.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_11_haisa.ipynb b/Desafio_11_haisa.ipynb new file mode 100644 index 0000000..ffe71f0 --- /dev/null +++ b/Desafio_11_haisa.ipynb @@ -0,0 +1,107 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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": 2, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "pSIzX4zUf6Jz" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(4, 2)" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Seu código\n", + "def contar_pares_impares(entrada):\n", + " pares = 0\n", + " impares = 0\n", + " for i in entrada:\n", + " if i%2 ==0:\n", + " pares = pares + 1\n", + " else:\n", + " impares = impares + 1\n", + " return (pares, impares)\n", + "\n", + "teste = [6,2,7,-5,8,-4]\n", + "\n", + "contar_pares_impares(teste)" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "OQG6erslSjri" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 11.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Desafio_12_haisa.ipynb b/Desafio_12_haisa.ipynb new file mode 100644 index 0000000..5fe6d95 --- /dev/null +++ b/Desafio_12_haisa.ipynb @@ -0,0 +1,118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "view-in-github" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "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", + "execution_count": 6, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "UGgtGYGGf6J3" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\"1234\": Senha inválida\n", + "\"Qw#1234\": Senha válida\n" + ] + } + ], + "source": [ + "def verificar_senha(senha):\n", + " mi, ma, nu, ca = 0, 0, 0, 0\n", + " senha = str(senha)\n", + " if (len(senha)>= 6 and len(senha)<=16):\n", + " for i in senha:\n", + " if (i.islower()):\n", + " mi+=1\n", + " if (i.isupper()):\n", + " ma+=1\n", + " if (i.isdigit()):\n", + " nu+=1\n", + " if (i=='$' or i=='@' or i=='#'):\n", + " ca+=1\n", + " if (mi>=1 and ma>=1 and nu>=1 and ca>=1 and mi+ma+nu+ca==len(senha)):\n", + " print(f'\"{senha}\": Senha válida') \n", + " else:\n", + " print(f'\"{senha}\": Senha inválida')\n", + "\n", + "verificar_senha(1234)\n", + "verificar_senha(\"Qw#1234\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "colab": { + "include_colab_link": true, + "name": "Desafio 12.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/README.md b/README.md index d1e16c8..2919f71 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # Desafios com Python -Nesta pasta estaremos colocando alguns desafios à serem resolvidos com Python. Abra-os no Jupyter notebook ou Google Colab, resolva-os e nos envie para revisão a partir de um pull request para a pasta da turma. +# (Python Challenges) + +## Curso Data Science (Data Science Class) - AWARI 2021 +## Aluna (Student): Haisa Vargas Echeli.