diff --git a/Desafio_01.ipynb b/Desafio_01.ipynb index db922b9..835ff26 100644 --- a/Desafio_01.ipynb +++ b/Desafio_01.ipynb @@ -24,13 +24,30 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 4, "metadata": { "colab": {}, "colab_type": "code", "id": "WhtbdwFseldD" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "Counter({'red': 4,\n", + " 'green': 4,\n", + " 'black': 5,\n", + " 'pink': 6,\n", + " 'white': 5,\n", + " 'eyes': 1,\n", + " 'orange': 4})" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "palavras = [\n", " 'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',\n", @@ -40,7 +57,9 @@ "]\n", "\n", "\n", - "# Seu código" + "# Seu código\n", + "from collections import Counter\n", + "Counter(palavras)" ] }, { @@ -77,7 +96,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_02.ipynb b/Desafio_02.ipynb index 8aa2264..6b8e4db 100644 --- a/Desafio_02.ipynb +++ b/Desafio_02.ipynb @@ -29,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 20, "metadata": { "colab": {}, "colab_type": "code", @@ -38,8 +38,45 @@ "outputs": [], "source": [ "def convert_to_sec(number):\n", - " pass # Seu código" + " if type(number) is not int:\n", + " return 'Erro'\n", + " else:\n", + " return number*3600 # Seu código" ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "18000" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "convert_to_sec(5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -64,7 +101,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_03.ipynb b/Desafio_03.ipynb index 75be003..74d2b58 100644 --- a/Desafio_03.ipynb +++ b/Desafio_03.ipynb @@ -24,17 +24,37 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 1, "metadata": { "colab": {}, "colab_type": "code", "id": "ndTkQEUBf6JS" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "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" + "# Seu código\n", + "\n", + "def remove_repetidos(lista):\n", + " l = []\n", + " for i in lista:\n", + " if i not in l:\n", + " l.append(i)\n", + " l.sort()\n", + " return l\n", + "remove_repetidos(lista)" ] }, { @@ -71,7 +91,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_04.ipynb b/Desafio_04.ipynb index bdab516..c1737f2 100644 --- a/Desafio_04.ipynb +++ b/Desafio_04.ipynb @@ -28,16 +28,71 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 2, "metadata": { "colab": {}, "colab_type": "code", "id": "I5TInJDaf6JW" }, + "outputs": [ + { + "data": { + "text/plain": [ + "'legal é Python'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Seu código\n", + "def ordem_inversa (sentence):\n", + " words = sentence.split(' ')\n", + " reverse_sentence = ' '.join(reversed(words)) \n", + " return reverse_sentence \n", + "ordem_inversa('Python é legal')\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [], "source": [ - "# Seu código" + "def inverte_texto (texto):\n", + " lista_invertida = texto.split(' ')[::-1]\n", + " return ' '.join(lista_invertida)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'legal é Python'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inverte_texto('Python é legal')" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -62,7 +117,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_05.ipynb b/Desafio_05.ipynb index 0794a31..b9d918e 100644 --- a/Desafio_05.ipynb +++ b/Desafio_05.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 2, "metadata": { "colab": {}, "colab_type": "code", @@ -59,16 +59,49 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 3, "metadata": { "colab": {}, "colab_type": "code", "id": "F8n1sN-4XrW3" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "['(885) 407-1719',\n", + " '(285) 608-2448',\n", + " '(554) 994-1517',\n", + " '(650) 684-1437',\n", + " '(311) 799-3883',\n", + " '(464) 788-2397',\n", + " '(255) 826-9050',\n", + " '(943) 769-1061',\n", + " '(596) 336-5508',\n", + " '(410) 665-4447',\n", + " '(765) 368-1506',\n", + " '(935) 875-2054',\n", + " '(812) 816-0881',\n", + " '(821) 642-8987',\n", + " '(511) 821-7870']" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#Seu código" + "#Seu código\n", + "list(set(numeros_telefone))" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -93,7 +126,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_06.ipynb b/Desafio_06.ipynb index 1381088..6ff0909 100644 --- a/Desafio_06.ipynb +++ b/Desafio_06.ipynb @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 4, "metadata": { "colab": {}, "colab_type": "code", @@ -54,13 +54,43 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 5, "metadata": { "colab": {}, "colab_type": "code", "id": "ly-N_Aq624RQ" }, "outputs": [], + "source": [ + "def junta_listas (lista_1,lista_2):\n", + " return list(set.intersection(set(lista_1),set(lista_2)))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2, 3, 5, 8, 13]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "junta_listas(a,b)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [] } ], @@ -86,7 +116,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_07.ipynb b/Desafio_07.ipynb index 55c90e7..333d730 100644 --- a/Desafio_07.ipynb +++ b/Desafio_07.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 3, "metadata": { "colab": {}, "colab_type": "code", @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 4, "metadata": { "colab": {}, "colab_type": "code", @@ -90,16 +90,54 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 6, "metadata": { "colab": {}, "colab_type": "code", "id": "_OSrDQ1noh62" }, - "outputs": [], + "outputs": [ + { + "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']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#Seu código." + "#Seu código.\n", + "def nao_entraram (a,b):\n", + " l= []\n", + " for i in a:\n", + " if i not in b:\n", + " l.append(i)\n", + " return l\n", + "nao_entraram(telefones_alunos,entraram_no_grupo)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -124,7 +162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_08.ipynb b/Desafio_08.ipynb index de5d802..a262450 100644 --- a/Desafio_08.ipynb +++ b/Desafio_08.ipynb @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 1, "metadata": { "colab": {}, "colab_type": "code", @@ -33,18 +33,123 @@ }, "outputs": [], "source": [ - "# Seu código" + "# Seu código\n", + "import string\n" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "pontuacao = string.punctuation" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "metadata": { "colab": {}, "colab_type": "code", "id": "ZYbqEWBG5nKx" }, "outputs": [], + "source": [ + "with open('texto.txt','r') as f:\n", + " texto = f.read()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'What is Python language? \\nPython 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 \\nlanguages such as C++ or Java. \\nPython 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.'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "texto" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "texto = texto.replace('\\n',' ')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "texto_sem_pontuacao = [letra if letra not in pontuacao else ' ' for letra in texto]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "texto_sem_pontuacao = \"\".join(texto_sem_pontuacao)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "palavras_unicas = list(set(texto_sem_pontuacao.split(' ')))" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['philosophy',\n", + " 'management',\n", + " 'emphasizes',\n", + " 'functional',\n", + " 'interpreted',\n", + " 'programming',\n", + " 'programmers',\n", + " 'readability',\n", + " 'intermediate',\n", + " 'comprehensive']" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sorted(palavras_unicas,key=len)[-10:]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [] } ], @@ -70,7 +175,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_09.ipynb b/Desafio_09.ipynb index 6fb29e1..bbb629a 100644 --- a/Desafio_09.ipynb +++ b/Desafio_09.ipynb @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 43, "metadata": { "colab": {}, "colab_type": "code", @@ -33,17 +33,45 @@ }, "outputs": [], "source": [ - "# Seu código" + "# Seu código\n", + "def func (x):\n", + " cont = 0\n", + " l = []\n", + " while (cont < x):\n", + " cont=cont+1\n", + " if cont%3 == 0 or cont%5 == 0:\n", + " l.append(cont)\n", + " soma = 0\n", + " for n in l:\n", + " soma = soma + n\n", + " print(soma)" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 44, "metadata": { "colab": {}, "colab_type": "code", "id": "a_6aqcKp6wrN" }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "98\n" + ] + } + ], + "source": [ + "func(20)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [] } @@ -70,7 +98,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/Desafio_10.ipynb b/Desafio_10.ipynb index 4f831f3..dbd7da3 100644 --- a/Desafio_10.ipynb +++ b/Desafio_10.ipynb @@ -34,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 1, "metadata": { "colab": {}, "colab_type": "code", @@ -42,17 +42,73 @@ }, "outputs": [], "source": [ - "# Seu código" + "# Seu código\n", + "def retorna_lista(lista):\n", + " tamanho_da_lista = len(lista)\n", + " if tamanho_da_lista%3 == 0:\n", + " tamanho_listinha = int(tamanho_da_lista/3)\n", + " for i in range(0,3):\n", + " listinha = lista[tamanho_listinha*i:tamanho_listinha*(i+1)][::-1]\n", + " print(f\"Parte {i+1}: {listinha}\")\n", + " return None\n", + " else: \n", + " return print(\"Nao divisivel por 3\")" ] }, { "cell_type": "code", - "execution_count": 0, + "execution_count": 2, "metadata": { "colab": {}, "colab_type": "code", "id": "pNrXNVqf8Wc1" }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Parte 1: [8, 45, 11]\n", + "Parte 2: [12, 14, 23]\n", + "Parte 3: [89, 45, 78]\n" + ] + } + ], + "source": [ + "retorna_lista([11, 45, 8, 23, 14, 12, 78, 45, 89])" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 2]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[1, 2, 3, 4, 5][0:2]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [] } @@ -79,7 +135,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.8.5" } }, "nbformat": 4,