From a5b39b3f4853ba19d6e43ab67fcdeaaad4831315 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 09:33:37 -0300
Subject: [PATCH 01/16] Created using Colaboratory
---
Desafio_01.ipynb | 244 +++++++++++++++++++++++++++++++----------------
1 file changed, 161 insertions(+), 83 deletions(-)
diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb
index db922b9..d0af99b 100644
--- a/Desafio_01.ipynb
+++ b/Desafio_01.ipynb
@@ -1,85 +1,163 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "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": 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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "id": "WhtbdwFseldD"
+ },
+ "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"
+ ],
+ "execution_count": 2,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "_3CxoCU18lwN"
+ },
+ "source": [
+ "#Solução com importando o Counter"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "M58o1U9KfAxa",
+ "outputId": "89bbd9a1-120b-4936-c5f2-2c931e62ffb3"
+ },
+ "source": [
+ "from collections import Counter\n",
+ "\n",
+ "print(Counter(palavras))"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Counter({'pink': 6, 'black': 5, 'white': 5, 'red': 4, 'green': 4, 'orange': 4, 'eyes': 1})\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "EZOWuzEc9Clb"
+ },
+ "source": [
+ "#Solução criando o Counter"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "1RJs2ga39Fuy",
+ "outputId": "d795db69-c7df-432e-b495-cc9025e8301e",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "def Counter(lista_de_palavras):\n",
+ " \n",
+ " palavras_unicas = []\n",
+ " dicionario_de_palavras = {}\n",
+ " \n",
+ " #Faz a contagem de palavras\n",
+ " for palavra in lista_de_palavras:\n",
+ " if palavra not in palavras_unicas:\n",
+ " palavras_unicas.append(palavra)\n",
+ " count = 0\n",
+ " for p in lista_de_palavras:\n",
+ " if p == palavra:\n",
+ " count+=1\n",
+ " dicionario_de_palavras[palavra] = count\n",
+ " \n",
+ " #Ordena as palavras pela quantidade\n",
+ " resultado = sorted(dicionario_de_palavras, key = dicionario_de_palavras.get, reverse=True)\n",
+ " \n",
+ " #Cria novo dicinario contendo os valores ordenados\n",
+ " n_dicionario = {}\n",
+ " for r in resultado:\n",
+ " n_dicionario[r] = dicionario_de_palavras[r]\n",
+ "\n",
+ " #Exporta dicionario \n",
+ " return n_dicionario\n",
+ "\n",
+ "print(Counter(palavras))"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "{'pink': 6, 'black': 5, 'white': 5, 'red': 4, 'green': 4, 'orange': 4, 'eyes': 1}\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From e3f2a6becb5b23173de3a314db7833f1128170fa Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 09:41:04 -0300
Subject: [PATCH 02/16] Created using Colaboratory
---
Desafio_02.ipynb | 167 +++++++++++++++++++++++++++--------------------
1 file changed, 97 insertions(+), 70 deletions(-)
diff --git a/Desafio_02.ipynb b/Desafio_02.ipynb
index 8aa2264..37c835f 100644
--- a/Desafio_02.ipynb
+++ b/Desafio_02.ipynb
@@ -1,72 +1,99 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "sSm6F7sff6JO"
- },
- "outputs": [],
- "source": [
- "def convert_to_sec(number):\n",
- " pass # Seu código"
- ]
- }
- ],
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "FygDNvm5BXfg"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "sSm6F7sff6JO",
+ "outputId": "e58378b3-e382-4e6f-81a4-d3d837a5d4d6"
+ },
+ "source": [
+ "def convert_to_sec(hour):\n",
+ " return hour*60*60\n",
+ "\n",
+ "print(convert_to_sec(5))\n",
+ "print(convert_to_sec(3))\n",
+ "print(convert_to_sec(2))"
+ ],
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "18000\n",
+ "10800\n",
+ "7200\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 5a0d4240d1d2f3994e340120848352977f403991 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 09:53:05 -0300
Subject: [PATCH 03/16] Created using Colaboratory
---
Desafio_03.ipynb | 169 ++++++++++++++++++++++++++---------------------
1 file changed, 92 insertions(+), 77 deletions(-)
diff --git a/Desafio_03.ipynb b/Desafio_03.ipynb
index 75be003..e5e1686 100644
--- a/Desafio_03.ipynb
+++ b/Desafio_03.ipynb
@@ -1,79 +1,94 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "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",
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "id": "ndTkQEUBf6JS"
+ },
+ "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"
+ ],
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "wo2rA-NriFtO",
+ "outputId": "15606b22-5ea0-4d0b-ee51-00fae5730508"
+ },
+ "source": [
+ "def sort_and_drop_duplicates(nlista):\n",
+ " xlista = []\n",
+ " for pos, number in enumerate(nlista):\n",
+ " if number not in xlista:\n",
+ " xlista.append(number)\n",
+ " \n",
+ " return(sorted(xlista, reverse=True))\n",
+ " \n",
+ "print(sort_and_drop_duplicates(lista))"
+ ],
+ "execution_count": 18,
+ "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 08ee68e090ea03b7ab1225f8516e4f63c0075674 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 10:03:27 -0300
Subject: [PATCH 04/16] Created using Colaboratory
---
Desafio_04.ipynb | 148 +++++++++++++++++++++++++----------------------
1 file changed, 80 insertions(+), 68 deletions(-)
diff --git a/Desafio_04.ipynb b/Desafio_04.ipynb
index bdab516..d66f61b 100644
--- a/Desafio_04.ipynb
+++ b/Desafio_04.ipynb
@@ -1,70 +1,82 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "I5TInJDaf6JW"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- }
- ],
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "I5TInJDaf6JW",
+ "outputId": "c2443ce9-47a3-4ac0-dde8-0e42e4e4c72d"
+ },
+ "source": [
+ "def inverte_texto(texto):\n",
+ " return texto.split(' ')[::-1]\n",
+ "\n",
+ "print(inverte_texto(\"Python é legal\"))"
+ ],
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "['legal', 'é', 'Python']\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From d233685ef0c440013ec13725da0dfd67884e5fd9 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 10:32:02 -0300
Subject: [PATCH 05/16] Created using Colaboratory
---
Desafio_05.ipynb | 290 +++++++++++++++++++++++++++++++----------------
1 file changed, 191 insertions(+), 99 deletions(-)
diff --git a/Desafio_05.ipynb b/Desafio_05.ipynb
index 0794a31..e7729a7 100644
--- a/Desafio_05.ipynb
+++ b/Desafio_05.ipynb
@@ -1,101 +1,193 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "F8n1sN-4XrW3"
- },
- "outputs": [],
- "source": [
- "#Seu código"
- ]
- }
- ],
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "id": "T68FjcUmWear"
+ },
+ "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",
+ "]"
+ ],
+ "execution_count": 2,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "cjLaWiOwMF_W"
+ },
+ "source": [
+ "#Utilizando SET"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "F8n1sN-4XrW3",
+ "outputId": "083c19fb-c932-4985-89f8-0394e753f2d1"
+ },
+ "source": [
+ "list(set(numeros_telefone))"
+ ],
+ "execution_count": 5,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['(311) 799-3883',\n",
+ " '(464) 788-2397',\n",
+ " '(285) 608-2448',\n",
+ " '(554) 994-1517',\n",
+ " '(943) 769-1061',\n",
+ " '(255) 826-9050',\n",
+ " '(821) 642-8987',\n",
+ " '(812) 816-0881',\n",
+ " '(511) 821-7870',\n",
+ " '(410) 665-4447',\n",
+ " '(650) 684-1437',\n",
+ " '(935) 875-2054',\n",
+ " '(765) 368-1506',\n",
+ " '(596) 336-5508',\n",
+ " '(885) 407-1719']"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 5
+ }
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "vDgsY_SANaDL"
+ },
+ "source": [
+ "#Sem o SET"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "YMrnJDViNZOS",
+ "outputId": "2b1cf70e-6d0e-4386-cb72-73d7a2c4b142",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ }
+ },
+ "source": [
+ "def drop_duplicates(nlista):\n",
+ " xlista = []\n",
+ " for n in nlista:\n",
+ " if n not in xlista:\n",
+ " xlista.append(n)\n",
+ " return xlista\n",
+ "\n",
+ "drop_duplicates(numeros_telefone)"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['(765) 368-1506',\n",
+ " '(285) 608-2448',\n",
+ " '(255) 826-9050',\n",
+ " '(554) 994-1517',\n",
+ " '(596) 336-5508',\n",
+ " '(511) 821-7870',\n",
+ " '(410) 665-4447',\n",
+ " '(821) 642-8987',\n",
+ " '(311) 799-3883',\n",
+ " '(935) 875-2054',\n",
+ " '(464) 788-2397',\n",
+ " '(650) 684-1437',\n",
+ " '(812) 816-0881',\n",
+ " '(885) 407-1719',\n",
+ " '(943) 769-1061']"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 6
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 07290245e55ec18ef0f3caf71bc6180417615b34 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 10:39:18 -0300
Subject: [PATCH 06/16] Created using Colaboratory
---
Desafio_06.ipynb | 207 ++++++++++++++++++++++++++---------------------
1 file changed, 115 insertions(+), 92 deletions(-)
diff --git a/Desafio_06.ipynb b/Desafio_06.ipynb
index 1381088..e3678b5 100644
--- a/Desafio_06.ipynb
+++ b/Desafio_06.ipynb
@@ -1,94 +1,117 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": null,
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "mvxpy_vCf6Jh"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "ly-N_Aq624RQ"
- },
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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": "TOtM2_bgOBaG"
+ },
+ "source": [
+ "**Listas**"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "JxF17MttOBaG"
+ },
+ "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]"
+ ],
+ "execution_count": 5,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "mvxpy_vCf6Jh",
+ "outputId": "539403f4-8826-42b1-d570-646ee9731b45"
+ },
+ "source": [
+ "def compara_lista(alista, blista):\n",
+ " final_lista = []\n",
+ " \n",
+ " if len(alista)>len(blista):\n",
+ " lista1 = alista\n",
+ " lista2 = blista\n",
+ " else:\n",
+ " lista1 = blista\n",
+ " lista2 = alista\n",
+ " \n",
+ " for a in lista1:\n",
+ " if a in lista2 and a not in final_lista:\n",
+ " final_lista.append(a)\n",
+ "\n",
+ " return final_lista\n",
+ "\n",
+ "compara_lista(a,b)"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[1, 2, 3, 5, 8, 13]"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 6
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 3aae0ef7ec6b458ff2c1d98834ef392d624fdc32 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 10:46:10 -0300
Subject: [PATCH 07/16] Created using Colaboratory
---
Desafio_07.ipynb | 289 ++++++++++++++++++++++++++---------------------
1 file changed, 159 insertions(+), 130 deletions(-)
diff --git a/Desafio_07.ipynb b/Desafio_07.ipynb
index 55c90e7..f8f12eb 100644
--- a/Desafio_07.ipynb
+++ b/Desafio_07.ipynb
@@ -1,132 +1,161 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "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": 0,
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "_OSrDQ1noh62"
- },
- "outputs": [],
- "source": [
- "#Seu código."
- ]
- }
- ],
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "id": "T68FjcUmWear"
+ },
+ "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",
+ " ]"
+ ],
+ "execution_count": 1,
+ "outputs": []
+ },
+ {
+ "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",
+ "metadata": {
+ "id": "0Hxk13ciXZ3h"
+ },
+ "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']"
+ ],
+ "execution_count": 3,
+ "outputs": []
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "_OSrDQ1noh62",
+ "outputId": "f48298ec-2caa-40f0-db44-e102e1cefcff"
+ },
+ "source": [
+ "def compara_lista(lista_alunos, lista_grupo):\n",
+ " lista_fora = []\n",
+ " \n",
+ " for aluno in lista_alunos:\n",
+ " if aluno not in lista_grupo:\n",
+ " lista_fora.append(aluno)\n",
+ "\n",
+ " return lista_fora\n",
+ "\n",
+ "compara_lista(telefones_alunos,entraram_no_grupo)"
+ ],
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "['(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']"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 4
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 7fa1d33baf718fed29ec7655526393135db0758a Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:13:05 -0300
Subject: [PATCH 08/16] Created using Colaboratory
---
Desafio_08.ipynb | 178 +++++++++++++++++++++++++++--------------------
1 file changed, 102 insertions(+), 76 deletions(-)
diff --git a/Desafio_08.ipynb b/Desafio_08.ipynb
index de5d802..57b4bc5 100644
--- a/Desafio_08.ipynb
+++ b/Desafio_08.ipynb
@@ -1,78 +1,104 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "EknxjSG0f6Jo"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- },
- {
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "EknxjSG0f6Jo",
+ "outputId": "5d2d55a9-8540-4bf4-b421-8719e130ce1d"
+ },
+ "source": [
+ "with open('texto.txt', \"r\") as documento:\n",
+ " data = documento.read().replace(')', ' ').replace('(', ' ').replace('\\ufeff', ' ').replace('.', ' ').replace(',', ' ').replace('\\n', ' ').strip().split(' ')\n",
+ "\n",
+ "#Conta o tamanho das palavras\n",
+ "words_len = {}\n",
+ "for word in data:\n",
+ " words_len[word] = len(word)\n",
+ "\n",
+ "#Ordena as palavras pelo tamanho\n",
+ "resultado = sorted(words_len, key = words_len.get, reverse=True)\n",
+ " \n",
+ "#Cria novo dicinario contendo os valores ordenados\n",
+ "n_dicionario = {}\n",
+ "for r in resultado:\n",
+ " n_dicionario[r] = words_len[r]\n",
+ "\n",
+ "for i, word in enumerate(n_dicionario):\n",
+ " if i < 10:\n",
+ " print(f'{word}: {len(word)}')\n",
+ "\n"
+ ],
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "general-purpose: 15\n",
+ "object-oriented: 15\n",
+ "comprehensive: 13\n",
+ "intermediate: 12\n",
+ "interpreted: 11\n",
+ "programming: 11\n",
+ "readability: 11\n",
+ "programmers: 11\n",
+ "high-level: 10\n",
+ "philosophy: 10\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 35f2bc0435cb9da60c51aec2f42f9517763135b1 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:23:34 -0300
Subject: [PATCH 09/16] Created using Colaboratory
---
Desafio_09.ipynb | 184 +++++++++++++++++++++++++++--------------------
1 file changed, 108 insertions(+), 76 deletions(-)
diff --git a/Desafio_09.ipynb b/Desafio_09.ipynb
index 6fb29e1..93ae926 100644
--- a/Desafio_09.ipynb
+++ b/Desafio_09.ipynb
@@ -1,78 +1,110 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "195C6bw-f6Js"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- },
- {
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "195C6bw-f6Js",
+ "outputId": "bd3b69e7-a961-49af-dd4e-1b0776350b49"
+ },
+ "source": [
+ "def multiplos(limite):\n",
+ " lista_multiplos = []\n",
+ "\n",
+ " #Calcula multiplos de 3\n",
+ " aux = 0\n",
+ " while True:\n",
+ " aux+=1\n",
+ " if 3*aux <= limite:\n",
+ " lista_multiplos.append(3*aux)\n",
+ " else:\n",
+ " break\n",
+ " #Calcula multiplos de 5\n",
+ " aux = 0\n",
+ " while True:\n",
+ " aux+=1\n",
+ " if 5*aux <= limite:\n",
+ " lista_multiplos.append(5*aux)\n",
+ " else:\n",
+ " break\n",
+ "\n",
+ " #retira duplicados \n",
+ " lista_multiplos = list(set(lista_multiplos))\n",
+ " \n",
+ " #soma lista\n",
+ " soma = 0\n",
+ " for i in lista_multiplos:\n",
+ " soma+=i\n",
+ " return soma\n",
+ "\n",
+ "multiplos(20)"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "98"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 6
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From d09c3e4037a10e7e55a638006c574c9d2d0e5c36 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:32:40 -0300
Subject: [PATCH 10/16] Created using Colaboratory
---
Desafio_10.ipynb | 187 ++++++++++++++++++++++++++---------------------
1 file changed, 102 insertions(+), 85 deletions(-)
diff --git a/Desafio_10.ipynb b/Desafio_10.ipynb
index 4f831f3..638e4d2 100644
--- a/Desafio_10.ipynb
+++ b/Desafio_10.ipynb
@@ -1,87 +1,104 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "IJ70pUjnf6Jw"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "pNrXNVqf8Wc1"
- },
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "IJ70pUjnf6Jw",
+ "outputId": "cc2efcba-8b57-4e43-c725-acd565d622eb"
+ },
+ "source": [
+ "def div_and_rev(lista):\n",
+ "\n",
+ " #Calcula tamanho das listas\n",
+ " tamanho = len(lista)/3\n",
+ " \n",
+ " #Separa as listas\n",
+ " nlista = []\n",
+ " for i in range(3):\n",
+ " inicio = i*tamanho\n",
+ " fim =(i+1)*tamanho\n",
+ " nlista.append(lista[int(inicio):int(fim)])\n",
+ " #Mostra na ordem inversa\n",
+ " for n in nlista:\n",
+ " print(n[::-1])\n",
+ "\n",
+ "\n",
+ "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]\n",
+ "div_and_rev(sampleList)"
+ ],
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[8, 45, 11]\n",
+ "[12, 14, 23]\n",
+ "[89, 45, 78]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 1f7796ad343d95afdc49fbbf17e979ba2c3f8943 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:36:28 -0300
Subject: [PATCH 11/16] Created using Colaboratory
---
Desafio_11.ipynb | 175 +++++++++++++++++++++++++----------------------
1 file changed, 92 insertions(+), 83 deletions(-)
diff --git a/Desafio_11.ipynb b/Desafio_11.ipynb
index b6a8536..3b8a2f2 100644
--- a/Desafio_11.ipynb
+++ b/Desafio_11.ipynb
@@ -1,85 +1,94 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "pSIzX4zUf6Jz"
- },
- "outputs": [],
- "source": [
- "# Seu código\n",
- "def contar_pares_impares(entrada):\n",
- " pass"
- ]
- },
- {
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "pSIzX4zUf6Jz",
+ "outputId": "3a31db1a-40af-4556-9527-094d29ec19a7"
+ },
+ "source": [
+ "# Seu código\n",
+ "def contar_pares_impares(entrada):\n",
+ " pares = 0\n",
+ " impares = 0\n",
+ "\n",
+ " for e in entrada:\n",
+ " if e%2 == 0:\n",
+ " pares+=1\n",
+ " else:\n",
+ " impares+=1\n",
+ "\n",
+ " return (pares,impares)\n",
+ "\n",
+ "print(contar_pares_impares([6,2,7,-5,8,-4]))"
+ ],
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "(4, 2)\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 7d61aeea416e161c04bcfe850fea6f55f2b9e653 Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:37:27 -0300
Subject: [PATCH 12/16] Created using Colaboratory
---
Desafio_11.ipynb | 44 ++++++++++++++++----------------------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/Desafio_11.ipynb b/Desafio_11.ipynb
index 3b8a2f2..d597a69 100644
--- a/Desafio_11.ipynb
+++ b/Desafio_11.ipynb
@@ -43,7 +43,7 @@
"id": "y1R0m4oWf6Jz"
},
"source": [
- "### Desafio 8\n",
+ "### Desafio 11\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",
@@ -57,38 +57,26 @@
{
"cell_type": "code",
"metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "pSIzX4zUf6Jz",
- "outputId": "3a31db1a-40af-4556-9527-094d29ec19a7"
+ "id": "pSIzX4zUf6Jz"
},
"source": [
"# Seu código\n",
"def contar_pares_impares(entrada):\n",
- " pares = 0\n",
- " impares = 0\n",
- "\n",
- " for e in entrada:\n",
- " if e%2 == 0:\n",
- " pares+=1\n",
- " else:\n",
- " impares+=1\n",
- "\n",
- " return (pares,impares)\n",
- "\n",
- "print(contar_pares_impares([6,2,7,-5,8,-4]))"
+ " pass"
],
- "execution_count": 2,
- "outputs": [
- {
- "output_type": "stream",
- "text": [
- "(4, 2)\n"
- ],
- "name": "stdout"
- }
- ]
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "metadata": {
+ "id": "OQG6erslSjri"
+ },
+ "source": [
+ ""
+ ],
+ "execution_count": null,
+ "outputs": []
}
]
}
\ No newline at end of file
From ab44a3e505a2678f5315e2e284e9d5049b50ab7a Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 11:48:48 -0300
Subject: [PATCH 13/16] Created using Colaboratory
---
Desafio_11.ipynb | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/Desafio_11.ipynb b/Desafio_11.ipynb
index d597a69..4aa9727 100644
--- a/Desafio_11.ipynb
+++ b/Desafio_11.ipynb
@@ -57,26 +57,37 @@
{
"cell_type": "code",
"metadata": {
- "id": "pSIzX4zUf6Jz"
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "pSIzX4zUf6Jz",
+ "outputId": "f41a7431-fb27-467b-a471-f439cca15551"
},
"source": [
- "# Seu código\n",
"def contar_pares_impares(entrada):\n",
- " pass"
- ],
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "code",
- "metadata": {
- "id": "OQG6erslSjri"
- },
- "source": [
- ""
+ " pares = 0\n",
+ " impares = 0\n",
+ " \n",
+ " for e in entrada:\n",
+ " if e%2 == 0:\n",
+ " pares+=1\n",
+ " else:\n",
+ " impares+=1\n",
+ " \n",
+ " return (pares,impares)\n",
+ "\n",
+ "print(contar_pares_impares([6,2,7,-5,8,-4]))"
],
- "execution_count": null,
- "outputs": []
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "(4, 2)\n"
+ ],
+ "name": "stdout"
+ }
+ ]
}
]
}
\ No newline at end of file
From d386bbeb6ac2515c40b1f27bd06a33f588b0123c Mon Sep 17 00:00:00 2001
From: BielSousa <36546452+BielSousa@users.noreply.github.com>
Date: Wed, 14 Jul 2021 16:05:27 -0300
Subject: [PATCH 14/16] Created using Colaboratory
---
Desafio_12.ipynb | 197 ++++++++++++++++++++++++++++-------------------
1 file changed, 116 insertions(+), 81 deletions(-)
diff --git a/Desafio_12.ipynb b/Desafio_12.ipynb
index 32aacf3..e1e64c2 100644
--- a/Desafio_12.ipynb
+++ b/Desafio_12.ipynb
@@ -1,83 +1,118 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "colab_type": "text",
- "id": "view-in-github"
- },
- "source": [
- ""
- ]
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "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"
+ }
},
- {
- "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": 0,
- "metadata": {
- "colab": {},
- "colab_type": "code",
- "id": "UGgtGYGGf6J3"
- },
- "outputs": [],
- "source": [
- "# Seu código"
- ]
- }
- ],
- "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.7.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "AYHY2YXQf6J2"
+ },
+ "source": [
+ "\n",
+ "### 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",
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "UGgtGYGGf6J3",
+ "outputId": "b678be7d-518f-4504-f3ff-a5180ec9d6f9"
+ },
+ "source": [
+ "import re\n",
+ "\n",
+ "def valida_senha(senha):\n",
+ "\n",
+ " regex = \"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$#])[A-Za-z\\d@$#]{6,20}$\"\n",
+ "\n",
+ " if re.search(regex, senha):\n",
+ " print(f'{senha} - senha valida')\n",
+ " else:\n",
+ " print(f'{senha} - senha invalida')\n",
+ "\n",
+ "valida_senha(\"1234\")\n",
+ "valida_senha(\"Qw#1234\")\n",
+ "valida_senha(\"12345678\") \n",
+ "valida_senha(\"J3sus0\")\n",
+ "valida_senha(\"#Te5t300\")\n",
+ "valida_senha(\"J*90j12374\")\n",
+ "valida_senha(\"Michheeul\")\n",
+ "valida_senha( \"Monk3y6\")"
+ ],
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "1234 - senha invalida\n",
+ "Qw#1234 - senha valida\n",
+ "12345678 - senha invalida\n",
+ "J3sus0 - senha invalida\n",
+ "#Te5t300 - senha valida\n",
+ "J*90j12374 - senha invalida\n",
+ "Michheeul - senha invalida\n",
+ "Monk3y6 - senha invalida\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From e9413682795eb6e0a201ef50643fa24e1c43897e Mon Sep 17 00:00:00 2001
From: Gabriel Farias <36546452+BielSousa@users.noreply.github.com>
Date: Thu, 12 Aug 2021 14:43:02 -0300
Subject: [PATCH 15/16] teste
---
Desafio_03.ipynb | 50 ++++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/Desafio_03.ipynb b/Desafio_03.ipynb
index e5e1686..9dbd653 100644
--- a/Desafio_03.ipynb
+++ b/Desafio_03.ipynb
@@ -1,6 +1,6 @@
{
"nbformat": 4,
- "nbformat_minor": 0,
+ "nbformat_minor": 2,
"metadata": {
"anaconda-cloud": {},
"colab": {
@@ -29,45 +29,39 @@
"cells": [
{
"cell_type": "markdown",
+ "source": [
+ "
"
+ ],
"metadata": {
"id": "view-in-github",
"colab_type": "text"
- },
- "source": [
- "
"
- ]
+ }
},
{
"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"
- ]
+ ],
+ "metadata": {
+ "id": "9apVxxygf6JR"
+ }
},
{
"cell_type": "code",
- "metadata": {
- "id": "ndTkQEUBf6JS"
- },
+ "execution_count": 1,
"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"
],
- "execution_count": 1,
- "outputs": []
+ "outputs": [],
+ "metadata": {
+ "id": "ndTkQEUBf6JS"
+ }
},
{
"cell_type": "code",
- "metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/"
- },
- "id": "wo2rA-NriFtO",
- "outputId": "15606b22-5ea0-4d0b-ee51-00fae5730508"
- },
+ "execution_count": 18,
"source": [
"def sort_and_drop_duplicates(nlista):\n",
" xlista = []\n",
@@ -79,16 +73,22 @@
" \n",
"print(sort_and_drop_duplicates(lista))"
],
- "execution_count": 18,
"outputs": [
{
"output_type": "stream",
+ "name": "stdout",
"text": [
"[45, 30, 15, 13, 9, 6, 5, 4, 3, 2, 1]\n"
- ],
- "name": "stdout"
+ ]
}
- ]
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "wo2rA-NriFtO",
+ "outputId": "15606b22-5ea0-4d0b-ee51-00fae5730508"
+ }
}
]
}
\ No newline at end of file
From 3bb40acc5f62e713dd31ac9cc451d01c48010d7e Mon Sep 17 00:00:00 2001
From: Gabriel Farias <36546452+BielSousa@users.noreply.github.com>
Date: Thu, 12 Aug 2021 18:41:40 -0300
Subject: [PATCH 16/16] Update README.md
Incrementando o readme
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index d1e16c8..fd65e9e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,4 @@
# 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.
+
+Estes notebooks estão com minhas resoluções dos exercícios.