Created
July 4, 2024 12:51
-
-
Save JoaoRoccella/cf76855e089a1f422754a77b248761b0 to your computer and use it in GitHub Desktop.
listas.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "provenance": [], | |
| "authorship_tag": "ABX9TyNuakLg2U0VvOQ55SVG8pBV", | |
| "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": [ | |
| "<a href=\"https://colab.research.google.com/gist/JoaoRoccella/cf76855e089a1f422754a77b248761b0/listas.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "# Listas" | |
| ], | |
| "metadata": { | |
| "id": "wqRUSX1Mfp2L" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 56, | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "oNCGAY77fn6_", | |
| "outputId": "318ae674-5460-45cc-817b-49f97c516f63" | |
| }, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha']\n", | |
| "<class 'list'>\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "legumes = [\"cenoura\", \"batata\", \"abobrinha\"]\n", | |
| "print(legumes)\n", | |
| "print(type(legumes))" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Acessando os items da lista" | |
| ], | |
| "metadata": { | |
| "id": "O4rbj1zdgT8s" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes[0])\n", | |
| "print(legumes[1])\n", | |
| "print(legumes[2])" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "Fq8FVJbWgTad", | |
| "outputId": "e5280d6c-33e8-472d-db9c-e26f69ad8abb" | |
| }, | |
| "execution_count": 57, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "cenoura\n", | |
| "batata\n", | |
| "abobrinha\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "for legume in legumes:\n", | |
| " print(legume)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "qMWK_AYxggO0", | |
| "outputId": "efb72c02-5ecd-4a8d-9b4a-2cc2548f44ff" | |
| }, | |
| "execution_count": 58, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "cenoura\n", | |
| "batata\n", | |
| "abobrinha\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# Lista mista\n", | |
| "listaMista = [\"banana\", 2, 3.14, True]\n", | |
| "print(listaMista)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "vXpb-fPKhCJL", | |
| "outputId": "40c821e0-cf67-4a3a-90d3-cab2c059da95" | |
| }, | |
| "execution_count": 59, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['banana', 2, 3.14, True]\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "listaValoresRepetidos = ['banana', 'banana', 'banana', 'banana']\n", | |
| "print(listaValoresRepetidos)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "s75oIygWhWo1", | |
| "outputId": "c4a351f4-07ea-4798-fae1-fa5a7ee7c3bc" | |
| }, | |
| "execution_count": 60, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['banana', 'banana', 'banana', 'banana']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# Tamanho das listas\n", | |
| "print(len(legumes)) # len -> length\n", | |
| "print(len(listaMista))\n", | |
| "print(len(listaValoresRepetidos))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "DS6fq8vChl45", | |
| "outputId": "6c00fb9b-c5b4-46d8-c994-0b5af37edab3" | |
| }, | |
| "execution_count": 61, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "3\n", | |
| "4\n", | |
| "4\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "fruta1 = \"banana\"\n", | |
| "fruta2 = \"maçã\"\n", | |
| "fruta3 = \"laranja\"\n", | |
| "\n", | |
| "listaFrutas = list((fruta1, fruta2, fruta3, \"abacaxi\"))\n", | |
| "print(listaFrutas)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "FYEZNeTsh67m", | |
| "outputId": "c37b10cc-b1d9-4123-9d01-975eaee40d2f" | |
| }, | |
| "execution_count": 62, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['banana', 'maçã', 'laranja', 'abacaxi']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# tupla\n", | |
| "tupla = (1, 2, 3)\n", | |
| "print(tupla)\n", | |
| "print(type(tupla))\n", | |
| "\n", | |
| "# conjunto\n", | |
| "conjunto = {1, 2, 3}\n", | |
| "print(conjunto)\n", | |
| "print(type(conjunto))\n", | |
| "\n", | |
| "# dicionário\n", | |
| "dicionario = {\"chave1\": 1, \"chave2\": 2, \"chave3\": 3}\n", | |
| "print(dicionario)\n", | |
| "print(type(dicionario))" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "pEgn0RWIirbC", | |
| "outputId": "07c63e88-facd-4619-eba4-1f72816d465c" | |
| }, | |
| "execution_count": 63, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "(1, 2, 3)\n", | |
| "<class 'tuple'>\n", | |
| "{1, 2, 3}\n", | |
| "<class 'set'>\n", | |
| "{'chave1': 1, 'chave2': 2, 'chave3': 3}\n", | |
| "<class 'dict'>\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Formas de se acessar os items de uma lista" | |
| ], | |
| "metadata": { | |
| "id": "WlDT4mD-j5mE" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "GJ-jLkxzj99i", | |
| "outputId": "66016ccf-91b5-448c-b719-47e9f7d4428a" | |
| }, | |
| "execution_count": 64, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes[-3])" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "MVu8SwE8kFcV", | |
| "outputId": "48c97a13-9d40-4cfe-eb94-f09120f17d06" | |
| }, | |
| "execution_count": 65, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "cenoura\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.append(\"mandioca\")\n", | |
| "legumes.append(\"vagem\")\n", | |
| "legumes.append(\"couve de bruxelas\")\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "FXZ5n8IzkoDq", | |
| "outputId": "c71764c5-d0c1-402b-9749-e97d87d8530c" | |
| }, | |
| "execution_count": 66, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'mandioca', 'vagem', 'couve de bruxelas']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes[1:-3])" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "vsXlA__pmQ3Z", | |
| "outputId": "ca0188ce-3279-4eec-b457-dbdb4514a6ae" | |
| }, | |
| "execution_count": 67, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['batata', 'abobrinha']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "Zc3OoQAcnvdk", | |
| "outputId": "a9c7db89-238e-4202-e092-f0c478e67ab1" | |
| }, | |
| "execution_count": 68, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'mandioca', 'vagem', 'couve de bruxelas']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes[4] = 'beterraba'\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "oEhwFIvtn1Mp", | |
| "outputId": "60608c96-9a08-47e8-95fb-34c056280f0d" | |
| }, | |
| "execution_count": 69, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'mandioca', 'beterraba', 'couve de bruxelas']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.insert(3, 'abobora')\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "VxfyeeaBoMn-", | |
| "outputId": "d4ed6116-db86-4874-aff3-c61d477d7635" | |
| }, | |
| "execution_count": 70, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'abobora', 'mandioca', 'beterraba', 'couve de bruxelas']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.remove('beterraba')\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "NxRc8MFhoqbU", | |
| "outputId": "9df75a0d-eba7-44fc-fb47-64d3ed00a4e6" | |
| }, | |
| "execution_count": 71, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'abobora', 'mandioca', 'couve de bruxelas']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.pop()\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "BX-DBRlto2c4", | |
| "outputId": "1045cd59-f644-41bc-d3d5-df54e008d4ab" | |
| }, | |
| "execution_count": 72, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobrinha', 'abobora', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.pop(2)\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "kFaxDIdnpC68", | |
| "outputId": "ef1cb8fd-10b5-4b70-95b5-f6bf8185cfcc" | |
| }, | |
| "execution_count": 73, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['cenoura', 'batata', 'abobora', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "# legumes.clear() remove todos os itens" | |
| ], | |
| "metadata": { | |
| "id": "US1qUHEIpq9U" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Percorrer itens de uma lista" | |
| ], | |
| "metadata": { | |
| "id": "Lsyb0bM0pxgJ" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "for item in legumes:\n", | |
| " print(item)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "84hIkiT8pxJ9", | |
| "outputId": "1996ee06-0efd-4c14-c568-3e4beff34e0c" | |
| }, | |
| "execution_count": 74, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "cenoura\n", | |
| "batata\n", | |
| "abobora\n", | |
| "mandioca\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "[print(item) for item in legumes]" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "fFb6Y6qFp66r", | |
| "outputId": "a31b5deb-0deb-4e65-f198-4efcf601e605" | |
| }, | |
| "execution_count": 75, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "cenoura\n", | |
| "batata\n", | |
| "abobora\n", | |
| "mandioca\n" | |
| ] | |
| }, | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "[None, None, None, None]" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 75 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "## Ordenação" | |
| ], | |
| "metadata": { | |
| "id": "Zsc2HG14qdXY" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.sort()\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "trKBNM1Tqf6u", | |
| "outputId": "4f6b1027-d665-43d1-9b41-72d68264c75a" | |
| }, | |
| "execution_count": 76, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['abobora', 'batata', 'cenoura', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.append(\"abobora\")\n", | |
| "legumes.append(\"mandioca\")\n", | |
| "legumes.append(\"cebola\")\n", | |
| "legumes.append(\"mandioca\")\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "T5rnGLhIq1mt", | |
| "outputId": "8c4264ea-c08e-490f-e7d4-ebab74ab73c9" | |
| }, | |
| "execution_count": 77, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['abobora', 'batata', 'cenoura', 'mandioca', 'abobora', 'mandioca', 'cebola', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.count(\"beterraba\")" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "PYCb_3OCrK-4", | |
| "outputId": "0cb47db6-d6bf-4601-d77b-80704d8eb367" | |
| }, | |
| "execution_count": 81, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": [ | |
| "0" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "execution_count": 81 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.sort()\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "jvZXjzlvrc4h", | |
| "outputId": "4f90aa74-da41-46c7-8a0c-d1286d93a7df" | |
| }, | |
| "execution_count": 82, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['abobora', 'abobora', 'batata', 'cebola', 'cenoura', 'mandioca', 'mandioca', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.sort(reverse=True)\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "UM_C8Ngyrg-8", | |
| "outputId": "38835ad8-b3dd-45cb-c0c0-8c5b8e6999ab" | |
| }, | |
| "execution_count": 86, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['mandioca', 'mandioca', 'mandioca', 'cenoura', 'cebola', 'batata', 'abobora', 'abobora']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "legumes.reverse()\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "U00oUVntrmDq", | |
| "outputId": "ee7e2b0a-4d3f-4704-e46f-77ace0c26bb2" | |
| }, | |
| "execution_count": 84, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['abobora', 'abobora', 'batata', 'cebola', 'cenoura', 'mandioca', 'mandioca', 'mandioca']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "print(legumes.index('mandioca'))\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "-wYmIVKosDx1", | |
| "outputId": "10759f67-6075-4caf-f743-089bf6e1367d" | |
| }, | |
| "execution_count": 91, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "0\n", | |
| "['mandioca', 'mandioca', 'mandioca', 'cenoura', 'cebola', 'batata', 'abobora', 'abobora']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "frutas = ['banana', 'maçã', 'laranja']\n", | |
| "legumes.extend(frutas)\n", | |
| "print(legumes)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "pHcuEYb3sm7j", | |
| "outputId": "6125fb0f-5a41-4878-a4a9-21ed1d3f1053" | |
| }, | |
| "execution_count": 92, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['mandioca', 'mandioca', 'mandioca', 'cenoura', 'cebola', 'batata', 'abobora', 'abobora', 'banana', 'maçã', 'laranja']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "sopaDeDoido = legumes.copy()\n", | |
| "print(sopaDeDoido)" | |
| ], | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/" | |
| }, | |
| "id": "REe4HeNys4fI", | |
| "outputId": "4de4fe7d-f1c6-49b9-9e4c-eb2e62fd45ef" | |
| }, | |
| "execution_count": 93, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "name": "stdout", | |
| "text": [ | |
| "['mandioca', 'mandioca', 'mandioca', 'cenoura', 'cebola', 'batata', 'abobora', 'abobora', 'banana', 'maçã', 'laranja']\n" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "### Exercícios\n", | |
| "\n", | |
| "1. Escreva um programa que solicite vários números ao usuário, um de cada vez, possibilitando encerrar a entrada de dados ao informar 'sair'.\n", | |
| "- Armazene os números em uma lista\n", | |
| "- Percorra esta lista alimentando outras duas listas, uma com números pares e outra com números ímpares.\n", | |
| "- Ordene e imprima os números pares e ímpares separadamente, mas em ordem crescente.\n", | |
| "- Some os valores de cada lista e imprima o resultado." | |
| ], | |
| "metadata": { | |
| "id": "H7u8dzY8wK_E" | |
| } | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment