diff --git a/Desafio_10_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_10_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..e783577 --- /dev/null +++ b/Desafio_10_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,158 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 10 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyM0o5DAV9vjIdntuusS8UH1", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "mZ7eDfdeJpXc" + } + }, + { + "cell_type": "markdown", + "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] " + ], + "metadata": { + "id": "U5fw_LumJpEU" + } + }, + { + "cell_type": "code", + "source": [ + "sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89]" + ], + "metadata": { + "id": "hccSagwTJx-9" + }, + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#Solução 1:\n", + "\n", + "n = 3\n", + "def Parte_1(lst, n): \n", + " for i in range(0, len(sampleList), n): \n", + " return list(reversed(lst[i:i + n]))\n", + "def Parte_2(lst, n):\n", + " for i in range(3,3+n,n):\n", + " return list(reversed(lst[i:i+n]))\n", + "def Parte_3(lst, n):\n", + " for i in range(6,6+n,n):\n", + " return list(reversed(lst[i:i+n]))\n", + "\n", + "print(f'Parte 1: {(Parte_1(sampleList, n))}'\n", + " f'\\nParte 2: {(Parte_2(sampleList, n))}'\n", + " f'\\nParte 3: {(Parte_3(sampleList, n))}')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "mTTuOT57aG3d", + "outputId": "9b336f30-547c-4ec6-e17c-bb8a692e2858" + }, + "execution_count": 31, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Parte 1: [8, 45, 11]\n", + "Parte 2: [12, 14, 23]\n", + "Parte 3: [89, 45, 78]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Solução 2: resposta da awari\n", + "l1 = []\n", + "l2 = []\n", + "l3 = []\n", + "qtde = len(sampleList) / 3\n", + "if qtde.is_integer():\n", + " for elem in sampleList:\n", + " if len(l1) < qtde:\n", + " l1.append(elem)\n", + " parte_1 = reversed(l1)\n", + " elif len(l2) < qtde:\n", + " l2.append(elem)\n", + " parte_2 = reversed(l2)\n", + " else:\n", + " if len(l3) < qtde:\n", + " l3.append(elem)\n", + " parte_3 = reversed(l3)\n", + " print(f'Parte 1: {list(parte_1)}'\n", + " f'\\nParte 2: {list(parte_2)}'\n", + " f'\\nParte 3: {list(parte_3)}')\n", + "else:\n", + " print('A respectiva lista não pode ser dividida em 3 partes iguais!')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "VCbwsZ2VehKA", + "outputId": "007f8353-6b1f-40c8-c578-f734941ab880" + }, + "execution_count": 25, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Parte 1: [8, 45, 11]\n", + "Parte 2: [12, 14, 23]\n", + "Parte 3: [89, 45, 78]\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_11_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_11_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..421dd62 --- /dev/null +++ b/Desafio_11_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,94 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 11 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyP/y9wswfpfNMfkO89d/P9c", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "Khf4Hipaom-h" + } + }, + { + "cell_type": "markdown", + "source": [ + "### 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", + "`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)`." + ], + "metadata": { + "id": "_NGs9dWWodso" + } + }, + { + "cell_type": "code", + "source": [ + "#solução 1:\n", + "lista_aleatoria=[22,24,26,27,29,31,33]\n", + "pares=[]\n", + "impares=[]\n", + "def imp_ou_par(lst):\n", + " for i in lst:\n", + " if i%2==0:\n", + " pares.append(i)\n", + " elif i%2!=0:\n", + " impares.append(i)\n", + " tupla=(len(pares),len(impares))\n", + " print(f'A quantidade de números pares é: {len(pares)}', f'e a quantidade de números ímpares é: {len(impares)}')\n", + " print(f'Logo, a tupla é: {tupla}')\n", + "imp_ou_par(lista_aleatoria)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "D5A-HqQIopuF", + "outputId": "e772a098-e827-48b3-8580-d7f48bac9007" + }, + "execution_count": 49, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "A quantidade de números pares é: 3 e a quantidade de números ímpares é: 4\n", + "Logo, a tupla é: (3, 4)\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_12_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_12_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..94919ee --- /dev/null +++ b/Desafio_12_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,217 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 12 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyN1B3CeubEslwNZiHhd77Fo", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "Khf4Hipaom-h" + } + }, + { + "cell_type": "markdown", + "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", + "```" + ], + "metadata": { + "id": "_NGs9dWWodso" + } + }, + { + "cell_type": "code", + "source": [ + "#Resposta 1: Awari" + ], + "metadata": { + "id": "ynQu_IqGyU3k" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "lista_senhas = ['12345678',\n", + " 'J3sus0',\n", + " '#Te5t300',\n", + " 'J*90j12374',\n", + " 'Michheeul',\n", + " 'Monk3y6',\n", + " '1234',\n", + " 'Qw#1234']" + ], + "metadata": { + "id": "Ih84NRo0aGxE" + }, + "execution_count": 86, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "import re\n", + "def valida_senhas(password):\n", + " regex = re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[$#@]).{6,16}$',\n", + " flags=re.M)\n", + " resultado = re.findall(regex, password)\n", + " if resultado:\n", + " print(f'\"{password}\" - Senha válida')\n", + " else:\n", + " print(f'\"{password}\" - Senha inválida')\n" + ], + "metadata": { + "id": "nJtDo945Z4jr" + }, + "execution_count": 87, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "for senha in lista_senhas:\n", + " valida_senhas(senha)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "mYfAf4EtZ9Ik", + "outputId": "9571d711-bb4c-4778-a59c-0e7279e2c9ed" + }, + "execution_count": 88, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\"12345678\" - Senha inválida\n", + "\"J3sus0\" - Senha inválida\n", + "\"#Te5t300\" - Senha válida\n", + "\"J*90j12374\" - Senha inválida\n", + "\"Michheeul\" - Senha inválida\n", + "\"Monk3y6\" - Senha inválida\n", + "\"1234\" - Senha inválida\n", + "\"Qw#1234\" - Senha válida\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "### Resposta 2: ERRADA, CORRIGIR COM MENTOR" + ], + "metadata": { + "id": "t5rIQy7VPx63" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "import re\n", + "senha=[\"12345678\", \"J3sus0\", \"#Te5t300\", \"J*90j12374\", \"Michheeul\", \"Monk3y6\"]\n", + "def validacao_senha(n):\n", + " min, mai, num, ces = 0, 0, 0, 0\n", + " if len(n)>=6 & len(n) <=16:\n", + " for i in n:\n", + " if i.islower:\n", + " min+=1\n", + " if i.isupper:\n", + " mai+=1\n", + " if i.isdigit:\n", + " num+=1\n", + " if re.match(r'^(?=.+[$#@])$',n): #####CORRIGIR PARTE DO REGEX\n", + " ces+=1\n", + " if (min>=1 & mai>=1 & num>=1 & ces>=1):\n", + " print(f'{n} - Senha válida') \n", + " else:\n", + " print(f'{n} - Senha inválida') \n", + " else:\n", + " print(f'{n} - Senha inválida')" + ], + "metadata": { + "id": "E18f1DpSr_2w" + }, + "execution_count": 84, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + " for s in senha:\n", + " validacao_senha(s)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "11-qFWj1Y40s", + "outputId": "641f0881-73b6-462c-b0c8-abc964813452" + }, + "execution_count": 85, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "12345678 - Senha inválida\n", + "J3sus0 - Senha inválida\n", + "#Te5t300 - Senha inválida\n", + "J*90j12374 - Senha inválida\n", + "Michheeul - Senha inválida\n", + "Monk3y6 - Senha inválida\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_1_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_1_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..8ecd048 --- /dev/null +++ b/Desafio_1_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,184 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 1 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "collapsed_sections": [], + "authorship_tag": "ABX9TyPjGxy2il8K34GItJLeNrOT", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "###**Resolução do Desafio 1 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38**" + ], + "metadata": { + "id": "dlI3SegUDwzM" + } + }, + { + "cell_type": "markdown", + "source": [ + "### Desafio 1\n", + "\n", + "Escreva um programa em Python para contabilizar a quantidade de ocorrências de cada palavra.\n" + ], + "metadata": { + "id": "EVfe6n01EzIk" + } + }, + { + "cell_type": "code", + "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", + "]" + ], + "metadata": { + "id": "P6bYkr3eE4dK" + }, + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#Opção 1:\n", + "from collections import Counter\n", + "dicionario = Counter(palavras)\n", + "dicionario" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "aLxpqRYMFyAL", + "outputId": "27ba8b8b-3c23-4a47-eda8-b36a90b81c67" + }, + "execution_count": 8, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "Counter({'black': 5,\n", + " 'eyes': 1,\n", + " 'green': 4,\n", + " 'orange': 4,\n", + " 'pink': 6,\n", + " 'red': 4,\n", + " 'white': 5})" + ] + }, + "metadata": {}, + "execution_count": 8 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Opção 2:\n", + "contagem={}\n", + "for n in palavras:\n", + " total=palavras.count(n)\n", + " contagem[f'{n}']=total\n", + "print(contagem)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Q2fiDUNYGgZ_", + "outputId": "03872bae-d829-4104-fe96-731f84f301f7" + }, + "execution_count": 9, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "{'red': 4, 'green': 4, 'black': 5, 'pink': 6, 'white': 5, 'eyes': 1, 'orange': 4}\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "#Opção 3:\n", + "for n in palavras:\n", + " print (n + \" \" + str(dicionario[n]) if n in palavras else 0)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pftwYNeuH-bb", + "outputId": "51632af5-d717-40e4-83e6-8d23191b23e4" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "red 4\n", + "green 4\n", + "black 5\n", + "pink 6\n", + "black 5\n", + "white 5\n", + "black 5\n", + "eyes 1\n", + "white 5\n", + "black 5\n", + "orange 4\n", + "pink 6\n", + "pink 6\n", + "red 4\n", + "red 4\n", + "white 5\n", + "orange 4\n", + "white 5\n", + "black 5\n", + "pink 6\n", + "green 4\n", + "green 4\n", + "pink 6\n", + "green 4\n", + "pink 6\n", + "white 5\n", + "orange 4\n", + "orange 4\n", + "red 4\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_2_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_2_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..38c2ee3 --- /dev/null +++ b/Desafio_2_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,91 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 2 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "collapsed_sections": [], + "authorship_tag": "ABX9TyPt9QtN37Aa0mwcbG+2QpnU", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "FrFjUlLrcTDh" + } + }, + { + "cell_type": "markdown", + "source": [ + "\n", + "### 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\n", + "\n" + ], + "metadata": { + "id": "BkVaOex-bcX4" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "5K3W-K-sbaRU", + "outputId": "a53dc8c1-3df4-4950-c348-dd3ce52b6584" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "3600\n", + "7200\n" + ] + } + ], + "source": [ + "#opção 1:\n", + "def convert_to_sec(number):\n", + " x=number * 3600\n", + " print(x)\n", + "convert_to_sec(1)\n", + "convert_to_sec(2)" + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_3_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_3_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..d3cd10c --- /dev/null +++ b/Desafio_3_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,125 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 3 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyO2MtgEsUX2sPasum3YeP9b", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "4JRUfqL_Z-Ht" + } + }, + { + "cell_type": "markdown", + "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." + ], + "metadata": { + "id": "x317kt0oZ95x" + } + }, + { + "cell_type": "code", + "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" + ], + "metadata": { + "id": "L8kOFW4MaDje" + }, + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "#opção 1:\n", + "\n", + "def lista_ordenada(n):\n", + " x=set(n)\n", + " y=sorted(x)\n", + " return list(x)\n", + "lista_ordenada(lista)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "I_LZdkyraGEy", + "outputId": "67741efd-663d-4601-bd78-d7c1db24e26d" + }, + "execution_count": 9, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 9, 13, 45, 15, 30]" + ] + }, + "metadata": {}, + "execution_count": 9 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#opção 2:\n", + "\n", + "from collections import OrderedDict\n", + "def lista_ordenada(n):\n", + " final_list = list(OrderedDict.fromkeys(lista))\n", + " print(final_list)\n", + "lista_ordenada(lista)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "YyyixjZ9cCKd", + "outputId": "7f3115da-55aa-40fd-dd1a-292e1c64f1ae" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[1, 2, 3, 4, 30, 5, 6, 9, 15, 13, 45]\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_4_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_4_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..2b866c3 --- /dev/null +++ b/Desafio_4_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,82 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 4 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyMTOwDCgFfFshjPFNAtLafb", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "zJMbmQmzfgfm" + } + }, + { + "cell_type": "markdown", + "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\"" + ], + "metadata": { + "id": "bo-dCPFwkpJ1" + } + }, + { + "cell_type": "code", + "source": [ + "import re\n", + "def inverter(frase, regex=re.compile(r\"[^\\-,.?!\\s]+\")):\n", + " return \" \".join(re.findall(regex, frase)[::-1])\n", + "\n", + "print(inverter(\"Eu roubei nessa questão porque não consegui resolver sozinho. Por isso, colei da internet.\"))\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "QDU3b--Bfuzr", + "outputId": "fd24c1c7-6407-4f44-d8c7-cf10f1c996f4" + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "internet da colei isso Por sozinho resolver consegui não porque questão nessa roubei Eu\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_5_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_5_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..a5c4a46 --- /dev/null +++ b/Desafio_5_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,125 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 5 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyPfswusC8qhDvSGedzVilRd", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "iqRQC7xmmSbp" + } + }, + { + "cell_type": "markdown", + "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?\n" + ], + "metadata": { + "id": "3zAOo1pDsM11" + } + }, + { + "cell_type": "code", + "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", + "]" + ], + "metadata": { + "id": "qecWje2MsL7L" + }, + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "numeros_telefone_novo=list(sorted(set(numeros_telefone)))\n", + "numeros_telefone_novo" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "mhoHYiADsL22", + "outputId": "82b832be-3393-4f32-d087-3f01628595f4" + }, + "execution_count": 8, + "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": 8 + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_6_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_6_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..0eb30d9 --- /dev/null +++ b/Desafio_6_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,197 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 6 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyPHjkLGeAUAA4p8PbI9Arc0", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "3YJTe3gaw4CW" + } + }, + { + "cell_type": "markdown", + "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" + ], + "metadata": { + "id": "QFyhVdGjw8Jv" + } + }, + { + "cell_type": "markdown", + "source": [ + "**Listas**" + ], + "metadata": { + "id": "nq5U0jf5xATE" + } + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "id": "iRBV_p97wex0" + }, + "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", + "source": [ + "#opção 1:\n", + "\n", + "def join_listas (x,y):\n", + " z=list(sorted(set([*x, *y])))\n", + " return z\n", + "join_listas(a,b)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "2UGGOdqExJAJ", + "outputId": "dc5d6604-88b0-4d8b-ab03-cc27a323b8db" + }, + "execution_count": 20, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 21, 34, 55, 89]" + ] + }, + "metadata": {}, + "execution_count": 20 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#opção 2:\n", + "\n", + "def join_listas (x,y):\n", + " z=x+y\n", + " return sorted(set(z))\n", + "join_listas(a,b)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "y1lLTKM71BN_", + "outputId": "7f89dd8e-b372-48ee-9e5e-e5960d2f3ee1" + }, + "execution_count": 21, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 21, 34, 55, 89]" + ] + }, + "metadata": {}, + "execution_count": 21 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#opção 3:\n", + "\n", + "def join_listas (x,y):\n", + " for i in y: \n", + " x.append(i)\n", + " return sorted(set(x))\n", + "join_listas(a,b)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "kSi-G-wBzWVs", + "outputId": "d314b80c-b813-4c7c-ebf3-dbc9d6b026d0" + }, + "execution_count": 22, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 21, 34, 55, 89]" + ] + }, + "metadata": {}, + "execution_count": 22 + } + ] + }, + { + "cell_type": "code", + "source": [ + "#opção 4:\n", + "import itertools \n", + "def join_listas(x,y):\n", + " z = list(itertools.chain(x,y))\n", + " return sorted(set(z))\n", + "join_listas(a,b)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "6GpfdfMs1nca", + "outputId": "e53bf4ee-c40e-47ed-bec9-336054961239" + }, + "execution_count": 24, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 21, 34, 55, 89]" + ] + }, + "metadata": {}, + "execution_count": 24 + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_7_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_7_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..210c242 --- /dev/null +++ b/Desafio_7_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,151 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 7 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyP+1YmAveHsugizZ7s2pmPu", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ], + "metadata": { + "id": "6p6QOo884QOI" + } + }, + { + "cell_type": "markdown", + "source": [ + "# Desafio 7\n", + "Um professor de universidade tem uma turma com os seguintes números de telefones:" + ], + "metadata": { + "id": "ic900xT74VZf" + } + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "MZSGneCT4OmF" + }, + "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", + "source": [ + "Ele criou um grupo do WhatsApp. No entanto, somente os seguintes números entraram no grupo:" + ], + "metadata": { + "id": "Y1HqZuT04kEU" + } + }, + { + "cell_type": "code", + "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']" + ], + "metadata": { + "id": "jB6gwIub4qc9" + }, + "execution_count": 2, + "outputs": [] + }, + { + "cell_type": "markdown", + "source": [ + "Você seria capaz de criar uma lista dos alunos que ainda não entraram no grupo para que sejam contatados individualmente?" + ], + "metadata": { + "id": "e0VxCfgA43qC" + } + }, + { + "cell_type": "code", + "source": [ + "from pprint import pprint\n", + "alunos = set(telefones_alunos)\n", + "alunos_grupo = set(entraram_no_grupo)\n", + "alunos_fora_grupo = sorted(list(alunos.difference(alunos_grupo)))\n", + "pprint(alunos_fora_grupo)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "IzvGkMlT46fM", + "outputId": "28bdb93a-5ced-45d1-e17f-8f399097e42b" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['(294) 430-7720',\n", + " '(300) 303-5462',\n", + " '(403) 343-7705',\n", + " '(491) 666-5367',\n", + " '(640) 427-2597',\n", + " '(641) 367-5279',\n", + " '(757) 450-9985',\n", + " '(797) 649-3653',\n", + " '(835) 955-1498',\n", + " '(856) 338-7094',\n", + " '(873) 810-8267',\n", + " '(897) 932-2512',\n", + " '(941) 225-3869',\n", + " '(964) 710-9625']\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Desafio_8_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_8_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..78b09f6 --- /dev/null +++ b/Desafio_8_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,106 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Desafio 8 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyMSSSI36flsE0MkU2NVRDau", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "![](https://i.imgur.com/YX6UATs.png)\n" + ], + "metadata": { + "id": "MacXeo6FTB7r" + } + }, + { + "cell_type": "markdown", + "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**)." + ], + "metadata": { + "id": "mqI_oC0ATGbk" + } + }, + { + "cell_type": "code", + "source": [ + "#colei porque não consegui fazer sozinho\n", + "\n", + "from operator import itemgetter\n", + "with open('texto.txt','r') as t_base:\n", + " dic={}\n", + " conteudo=t_base.read().replace('.',' ').replace('-', \" \").replace(',',' ').replace(')', ' ')\n", + " for palavra in conteudo.split():\n", + " dic[f'{palavra}']=len(palavra)\n", + " ordem=sorted(dic.items(),key=itemgetter(1),reverse=True)\n", + " for k, v in enumerate(ordem):\n", + " if k < 10:\n", + " print(v[0],v[1])" + ], + "metadata": { + "id": "IX-Z5n1ATKGR", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "8bdc06bf-6559-4606-ed36-1c6ea0dc65c4" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "comprehensive 13\n", + "intermediate 12\n", + "interpreted 11\n", + "programming 11\n", + "readability 11\n", + "programmers 11\n", + "philosophy 10\n", + "emphasizes 10\n", + "imperative 10\n", + "functional 10\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "" + ], + "metadata": { + "id": "ouy8i6u24W3U" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Desafio_9_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb b/Desafio_9_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb new file mode 100644 index 0000000..589f47f --- /dev/null +++ b/Desafio_9_de_Python_Awari_Data_Sciece_Aluno_Marcilio_Duarte_Turma_DS38.ipynb @@ -0,0 +1,92 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "49Sr3EsN6B9a" + }, + "source": [ + "![](https://i.imgur.com/YX6UATs.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "c1J5PNGv6GK_" + }, + "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": "KoZW8Ebu-sOp" + }, + "outputs": [], + "source": [ + "def soma_mt_3e5(x):\n", + " y=[a for a in range(1, x+1) if a%3==0 or a%5==0]\n", + " soma=sum(y)\n", + " return soma" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qPKCOqEyAhUX", + "outputId": "5585534e-a95f-4e30-cac6-e23d99295347" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "98" + ] + }, + "metadata": {}, + "execution_count": 21 + } + ], + "source": [ + "soma_mt_3e5(20)" + ] + } + ], + "metadata": { + "colab": { + "name": "Desafio 9 de Python - Awari_Data Sciece - Aluno: Marcilio Duarte_Turma_DS38", + "provenance": [], + "authorship_tag": "ABX9TyO7xNNT7IWz9/+AxLeM8aGw", + "include_colab_link": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file diff --git a/texto.txt b/texto.txt deleted file mode 100644 index 68b9e9c..0000000 --- a/texto.txt +++ /dev/null @@ -1,4 +0,0 @@ -What is Python language? -Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in -languages such as C++ or Java. -Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles.It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with Python. \ No newline at end of file