Skip to content
51 changes: 46 additions & 5 deletions Desafio_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.7"
"version": "3.7.9-final"
},
"colab": {
"name": "Desafio 1.ipynb",
Expand Down Expand Up @@ -67,7 +67,7 @@
"\n",
"# Seu código"
],
"execution_count": 0,
"execution_count": 22,
"outputs": []
},
{
Expand All @@ -78,10 +78,51 @@
"colab": {}
},
"source": [
""
"# import necessary libraries\n",
"import numpy as np\n",
"from operator import itemgetter\n",
"\n",
"# get unique values and its frequencies\n",
"words, frequencies = np.unique(palavras, return_counts=True)"
],
"execution_count": 0,
"execution_count": 23,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"# zip words and frequencies for iteration\n",
"stats = list(zip(words, frequencies))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Word: black\tFrequency: 5\nWord: eyes\tFrequency: 1\nWord: green\tFrequency: 4\nWord: orange\tFrequency: 4\nWord: pink\tFrequency: 6\nWord: red\tFrequency: 4\nWord: white\tFrequency: 5\n"
]
}
],
"source": [
"# print the word and its frequency\n",
"for stat in stats:\n",
" print(f'Word: {itemgetter(0)(stat)}\\tFrequency: {itemgetter(1)(stat)}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
}
78 changes: 73 additions & 5 deletions Desafio_02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.9-final"
},
"colab": {
"name": "Desafio 2.ipynb",
Expand Down Expand Up @@ -65,11 +65,79 @@
"colab": {}
},
"source": [
"def convert_to_sec(number):\n",
" pass # Seu código"
"def convert_to_sec(hours):\n",
" '''Converts hours to seconds'''\n",
" return hours * 60 * 60"
],
"execution_count": 0,
"execution_count": 1,
"outputs": []
},
{
"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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
}
41 changes: 36 additions & 5 deletions Desafio_03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.9-final"
},
"colab": {
"name": "Desafio 3.ipynb",
Expand Down Expand Up @@ -61,7 +61,7 @@
"\n",
"# Seu código"
],
"execution_count": 0,
"execution_count": 3,
"outputs": []
},
{
Expand All @@ -72,10 +72,41 @@
"colab": {}
},
"source": [
""
"# import necessary libraries\n",
"import numpy as np"
],
"execution_count": 0,
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# get unique values and sort the list\n",
"un_values = sorted(np.unique(lista))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]"
]
},
"metadata": {},
"execution_count": 11
}
],
"source": [
"un_values"
]
}
]
}
}
36 changes: 29 additions & 7 deletions Desafio_04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.9-final"
},
"colab": {
"name": "Desafio 4.ipynb",
Expand Down Expand Up @@ -61,9 +61,13 @@
"colab": {}
},
"source": [
"# Seu código"
"# Seu código\n",
"def reverse_text(phrase):\n",
" '''Reverses the order of words in a string'''\n",
" phrase = list(reversed(phrase.split(' ')))\n",
" return ' '.join(phrase)\n"
],
"execution_count": 0,
"execution_count": 2,
"outputs": []
},
{
Expand All @@ -74,10 +78,28 @@
"colab": {}
},
"source": [
""
"reverse_text('Python é legal')"
],
"execution_count": 0,
"outputs": []
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'legal é Python'"
]
},
"metadata": {},
"execution_count": 3
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
}
60 changes: 49 additions & 11 deletions Desafio_05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
"display_name": "Python 3",
"language": "python"
}
},
"cells": [
Expand Down Expand Up @@ -68,7 +69,7 @@
"'(255) 826-9050',\n",
"]"
],
"execution_count": 0,
"execution_count": 16,
"outputs": []
},
{
Expand All @@ -83,16 +84,53 @@
},
{
"cell_type": "code",
"metadata": {
"id": "F8n1sN-4XrW3",
"colab_type": "code",
"colab": {}
},
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
""
"def no_dups(numbers):\n",
" '''Recursively removes duplicate elements of a list'''\n",
" if numbers == []:\n",
" return []\n",
" else:\n",
" head, *tail = numbers\n",
" numbers = [head] + no_dups(list(filter(lambda x: x != head, tail)))\n",
" return numbers"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['(765) 368-1506',\n",
" '(285) 608-2448',\n",
" '(255) 826-9050',\n",
" '(554) 994-1517',\n",
" '(596) 336-5508',\n",
" '(511) 821-7870',\n",
" '(410) 665-4447',\n",
" '(821) 642-8987',\n",
" '(311) 799-3883',\n",
" '(935) 875-2054',\n",
" '(464) 788-2397',\n",
" '(650) 684-1437',\n",
" '(812) 816-0881',\n",
" '(885) 407-1719',\n",
" '(943) 769-1061']"
]
},
"metadata": {},
"execution_count": 18
}
],
"execution_count": 0,
"outputs": []
"source": [
"no_dups(numeros_telefone)"
]
}
]
}
}
Loading