Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 56 additions & 11 deletions Desafio_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": 41,
"metadata": {
"colab": {},
"colab_type": "code",
Expand All @@ -37,20 +37,65 @@
" '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",
"]"
]
},
{
"source": [
"### Considera cada palavra uma chave de um dicionário. Se a chave não existir, cria e atribui valor 1. Se existir, adiciona 1 ao valor da chave"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"def contagem(lista): \n",
"\n",
" resultado = {}\n",
"\n",
"# Seu código"
" for palavra in lista:\n",
" resultado[palavra] = resultado.get(palavra, 0) + 1\n",
" \n",
" resultado = dict(sorted(resultado.items(), key= lambda item: item[1]))\n",
"\n",
" return resultado\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "M58o1U9KfAxa"
},
"execution_count": 43,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'eyes': 1,\n",
" 'red': 4,\n",
" 'green': 4,\n",
" 'orange': 4,\n",
" 'black': 5,\n",
" 'white': 5,\n",
" 'pink': 6}"
]
},
"metadata": {},
"execution_count": 43
}
],
"source": [
"contagem(palavras)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -77,9 +122,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
}
69 changes: 65 additions & 4 deletions Desafio_02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": 1,
"metadata": {
"colab": {},
"colab_type": "code",
Expand All @@ -38,7 +38,68 @@
"outputs": [],
"source": [
"def convert_to_sec(number):\n",
" pass # Seu código"
" \n",
" return number*3600"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"18000"
]
},
"metadata": {},
"execution_count": 2
}
],
"source": [
"convert_to_sec(5)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"10800"
]
},
"metadata": {},
"execution_count": 3
}
],
"source": [
"convert_to_sec(3)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"7200"
]
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"convert_to_sec(2)"
]
}
],
Expand All @@ -64,9 +125,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
}
78 changes: 65 additions & 13 deletions Desafio_03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,81 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": 13,
"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"
"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]"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "wo2rA-NriFtO"
},
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": []
"source": [
"def arruma_lista(lista):\n",
" \n",
" lista.sort()\n",
"\n",
" numero_anterior = lista[0]\n",
"\n",
" for numero in lista[1:]:\n",
" if numero == numero_anterior:\n",
" lista.pop(numero)\n",
" else:\n",
" numero_anterior = numero\n",
"\n",
" return lista"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]"
]
},
"metadata": {},
"execution_count": 15
}
],
"source": [
"arruma_lista(lista)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]"
]
},
"metadata": {},
"execution_count": 16
}
],
"source": [
"#Maneira sintética\n",
"def arruma_lista_sintetico(lista):\n",
" return sorted(set(lista))\n",
"\n",
"arruma_lista_sintetico(lista)"
]
}
],
"metadata": {
Expand All @@ -71,9 +123,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
}
51 changes: 47 additions & 4 deletions Desafio_04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,58 @@
},
{
"cell_type": "code",
"execution_count": 0,
"execution_count": 5,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "I5TInJDaf6JW"
},
"outputs": [],
"source": [
"# Seu código"
"def inverte_texto(frase):\n",
" \n",
" return ' '.join(frase.split()[::-1])\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'legal é Python'"
]
},
"metadata": {},
"execution_count": 6
}
],
"source": [
"inverte_texto(\"Python é legal\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'Roma de rei do roupa a roeu rato O'"
]
},
"metadata": {},
"execution_count": 7
}
],
"source": [
"inverte_texto(\"O rato roeu a roupa do rei de Roma\")"
]
}
],
Expand All @@ -62,9 +105,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
}
Loading