diff --git a/Desafios.ipynb b/Desafios.ipynb index a5dd920..4d5d683 100755 --- a/Desafios.ipynb +++ b/Desafios.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -48,9 +48,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[3], line 14\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m n\n\u001b[0;32m 13\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m---> 14\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[43mdigital_root\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m16\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 15\u001b[0m b \u001b[38;5;241m=\u001b[39m digital_root(\u001b[38;5;241m942\u001b[39m)\n\u001b[0;32m 16\u001b[0m c \u001b[38;5;241m=\u001b[39m digital_root(\u001b[38;5;241m132189\u001b[39m)\n", + "Cell \u001b[1;32mIn[3], line 8\u001b[0m, in \u001b[0;36mdigital_root\u001b[1;34m(n)\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m y \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m 7\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(y):\n\u001b[1;32m----> 8\u001b[0m x \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(n[i])\n\u001b[0;32m 9\u001b[0m n \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(x)\n\u001b[0;32m 10\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(n)\n", + "\u001b[1;31mKeyboardInterrupt\u001b[0m: " + ] + } + ], "source": [ "#Desafio 2: Retornar a soma dos algarismos de um número inteiro até que o resultado seja de apenas 1 algarismo:\n", "def digital_root(n):\n", @@ -75,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -128,23 +141,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3, 5]\n", - "[11, 23]\n", - "[2, 3, 4, 6, 8, 12]\n", - "[5]\n", - "13 is prime\n", - "3 is prime\n", - "29 is prime\n" - ] - } - ], + "outputs": [], "source": [ "#Desafio 3: Solução alternativa\n", "\n", @@ -173,18 +172,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[5, 9, 4, 8]\n", - "-4\n" - ] - } - ], + "outputs": [], "source": [ "import sys\n", "import math\n", @@ -209,19 +199,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "toLove\n", - "['Eu', 'sou', 'o', 'Batman']\n", - "souo\n" - ] - } - ], + "outputs": [], "source": [ "# Concatena e imprime as palavras do meio de strings se o len for par e imprime a palavra do meio se o len for impar\n", "\n", @@ -254,14 +234,18 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 1, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "dcba\n" + "ename": "IndexError", + "evalue": "string index out of range", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[1], line 12\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(x) \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(x) \u001b[38;5;241m<\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m9\u001b[39m:\n\u001b[0;32m 11\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m x:\n\u001b[1;32m---> 12\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[43mline\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m\n\u001b[0;32m 13\u001b[0m z\u001b[38;5;241m.\u001b[39mappend(y)\n\u001b[0;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(z))\n", + "\u001b[1;31mIndexError\u001b[0m: string index out of range" ] } ], @@ -285,17 +269,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], + "outputs": [], "source": [ "# O código verifica quantas jarras de suco são possíveis ser feitas dada uma sequência de caracteres indicando a quantidade de frutas:\n", "n = int(input())\n", @@ -324,14 +300,14 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "A=12.5664\n" + "A=78.5397\n" ] } ], @@ -345,17 +321,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A=70685.7750\n" - ] - } - ], + "outputs": [], "source": [ "# Formatação Numérica - {area:.4f} - area: variavel com o valor, .4f - numero da casas decimais\n", "raio = float(input())\n", @@ -367,19 +335,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12.5664\n", - "31819.3103\n", - "70685.775\n" - ] - } - ], + "outputs": [], "source": [ "def area(raio):\n", " n = 3.14159\n", @@ -394,17 +352,9 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "MEDIA = 6.43182\n" - ] - } - ], + "outputs": [], "source": [ "A = float(input())\n", "while A < 0 and A > 10:\n", @@ -420,14 +370,14 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "MEDIA = 7.5\n" + "MEDIA = 22.5\n" ] } ], @@ -451,14 +401,14 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "DIFERENCA = 86\n" + "DIFERENCA = -4312\n" ] } ], @@ -477,15 +427,15 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "NUMBER = 6\n", - "SALARY = U$ 2254.75\n" + "NUMBER = 2\n", + "SALARY = U$ 1100.00\n" ] } ], @@ -502,22 +452,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[1;32mc:\\GitHub\\Projetos_Python\\Desafios.ipynb Célula: 17\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m \u001b[39mrange\u001b[39m(n):\n\u001b[0;32m 16\u001b[0m sequencias \u001b[39m=\u001b[39m (\u001b[39minput\u001b[39m() \u001b[39m+\u001b[39m\u001b[39m'\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m'\u001b[39m \u001b[39m+\u001b[39m \u001b[39minput\u001b[39m())\u001b[39m.\u001b[39msplit(\u001b[39m'\u001b[39m\u001b[39m\\n\u001b[39;00m\u001b[39m'\u001b[39m)\n\u001b[1;32m---> 17\u001b[0m \u001b[39mprint\u001b[39m(compRNA(sequencias))\n", - "\u001b[1;32mc:\\GitHub\\Projetos_Python\\Desafios.ipynb Célula: 17\u001b[0m in \u001b[0;36mcompRNA\u001b[1;34m(seq)\u001b[0m\n\u001b[0;32m 8\u001b[0m diferencas \u001b[39m=\u001b[39m \u001b[39m1\u001b[39m \n\u001b[0;32m 9\u001b[0m \u001b[39mif\u001b[39;00m seq[\u001b[39m0\u001b[39m][i] \u001b[39m!=\u001b[39m \u001b[39m'\u001b[39m\u001b[39m.\u001b[39m\u001b[39m'\u001b[39m \u001b[39mand\u001b[39;00m seq[\u001b[39m1\u001b[39m][i] \u001b[39m!=\u001b[39m \u001b[39m'\u001b[39m\u001b[39m.\u001b[39m\u001b[39m'\u001b[39m \u001b[39mand\u001b[39;00m seq[\u001b[39m0\u001b[39m][i] \u001b[39m!=\u001b[39m seq[\u001b[39m1\u001b[39m][i]:\n\u001b[1;32m---> 10\u001b[0m \u001b[39mwhile\u001b[39;00m seq[\u001b[39m0\u001b[39;49m][i\u001b[39m+\u001b[39;49m\u001b[39m1\u001b[39;49m] \u001b[39m!=\u001b[39;49m seq[\u001b[39m1\u001b[39;49m][i\u001b[39m+\u001b[39;49m\u001b[39m1\u001b[39;49m]:\n\u001b[0;32m 11\u001b[0m diferencas \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[0;32m 12\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mf\u001b[39m\u001b[39m'\u001b[39m\u001b[39mMutações: \u001b[39m\u001b[39m{\u001b[39;00mdiferencas\u001b[39m}\u001b[39;00m\u001b[39m'\u001b[39m\n", - "\u001b[1;31mKeyboardInterrupt\u001b[0m: " - ] - } - ], + "outputs": [], "source": [ "#sequencias = (input() +'\\n' + input()).split('\\n')\n", "#print(sequencias)\n", @@ -540,17 +477,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "TOTAL = R$702.50\n" - ] - } - ], + "outputs": [], "source": [ "#Salario com Bonus\n", "\n", @@ -563,17 +492,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "TOTAL = R$702.50\n" - ] - } - ], + "outputs": [], "source": [ "nome = input()\n", "salario = float(input())\n", @@ -586,17 +507,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "VALOR A PAGAR: R$ 15.50\n" - ] - } - ], + "outputs": [], "source": [ "# Calculo Simples\n", "\n", @@ -623,21 +536,9 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "TRIANGULO: 7.800\n", - "CIRCULO: 84.949\n", - "TRAPEZIO: 18.200\n", - "QUADRADO: 16.000\n", - "RETANGULO: 12.000\n" - ] - } - ], + "outputs": [], "source": [ "# Areas\n", "A, B, C = input().split()\n", @@ -654,17 +555,9 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "106 eh o maior\n" - ] - } - ], + "outputs": [], "source": [ "# O Maior\n", "num = list(map(int, input().split()))\n", @@ -673,17 +566,9 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "14.286 km/l\n" - ] - } - ], + "outputs": [], "source": [ "# Consumo\n", "dist = int(input())\n", @@ -694,17 +579,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4.4721\n" - ] - } - ], + "outputs": [], "source": [ "# Distancia entre 2 pontos:\n", "\n", @@ -716,17 +593,9 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "220 minutos\n" - ] - } - ], + "outputs": [], "source": [ "# Distancia entre Veiculos:\n", "dist = int(input())\n", @@ -736,17 +605,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "70.833\n" - ] - } - ], + "outputs": [], "source": [ "# Gasto de combustivel\n", "tempo = float(input())\n", @@ -757,24 +618,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7835\n", - "78 nota(s) de R$ 100,00\n", - "0 nota(s) de R$ 50,00\n", - "1 nota(s) de R$ 20,00\n", - "1 nota(s) de R$ 10,00\n", - "1 nota(s) de R$ 5,00\n", - "0 nota(s) de R$ 2,00\n", - "0 nota(s) de R$ 1,00\n" - ] - } - ], + "outputs": [], "source": [ "# Numero em Cedulas\n", "valor = int(input())\n", @@ -792,18 +638,9 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0:9:16\n", - "0:9:16\n" - ] - } - ], + "outputs": [], "source": [ "# Converter Tempo em Segundos\n", "\n", @@ -821,23 +658,9 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 ano(s)\n", - "1 mes(es)\n", - "5 dia(s)\n", - "1 ano(s)\n", - "1 mes(es)\n", - "5 dia(s)\n", - "1 1 5\n" - ] - } - ], + "outputs": [], "source": [ "# Idade em Dias\n", "\n", @@ -856,31 +679,9 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "NOTAS:\n", - "5 nota(s) de R$ 100.00\n", - "1 nota(s) de R$ 50.00\n", - "1 nota(s) de R$ 20.00\n", - "0 nota(s) de R$ 10.00\n", - "1 nota(s) de R$ 5.00\n", - "0 nota(s) de R$ 2.00\n", - "MOEDAS:\n", - "1 moeda(s) de R$ 1.00\n", - "1 moeda(s) de R$ 0.50\n", - "0 moeda(s) de R$ 0.25\n", - "2 moeda(s) de R$ 0.10\n", - "0 moeda(s) de R$ 0.05\n", - "3 moeda(s) de R$ 0.01\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "valor = float(input())\n", "if valor >= 0 and valor <= 1000000.00:\n", @@ -904,19 +705,9 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carregadores do Box 1: 7\n", - "Carregadores do Box 2: 4\n", - "Carregadores do Box 3: 4\n" - ] - } - ], + "outputs": [], "source": [ "# Balancear carregadores\n", "\n", @@ -944,19 +735,9 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Explorador: 1 passo\n", - "Explorador: 2 passos\n", - "Explorador: 3 passos\n" - ] - } - ], + "outputs": [], "source": [ "passo = int(input())\n", "\n", @@ -980,20 +761,9 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Lista de itens:\n", - "- lobo\n", - "- ovo\n", - "- bobo\n" - ] - } - ], + "outputs": [], "source": [ "# Lista para armazenar os itens\n", "itens = []\n", @@ -1018,17 +788,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "132\n" - ] - } - ], + "outputs": [], "source": [ "capacidade_atual, aumento_percentual = map(int, input().split())\n", "\n",