Skip to content
96 changes: 96 additions & 0 deletions Desafio_01_haisa.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"![](https://i.imgur.com/YX6UATs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "SbLLE9q1eldC"
},
"source": [
"### Desafio 1\n",
"\n",
"Escreva um programa em Python para contabilizar a quantidade de ocorrências de cada palavra."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "WhtbdwFseldD"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Counter({'pink': 6, 'black': 5, 'white': 5, 'red': 4, 'green': 4, 'orange': 4, 'eyes': 1})\n"
]
}
],
"source": [
"palavras = [\n",
" 'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',\n",
" '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",
"\n",
"import collections\n",
"contar_palavras = collections.Counter(palavras)\n",
"\n",
"print(contar_palavras)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "M58o1U9KfAxa"
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"include_colab_link": true,
"name": "Desafio 1.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
92 changes: 92 additions & 0 deletions Desafio_02_haisa.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](https://i.imgur.com/YX6UATs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "q1NCks7Af6JN"
},
"source": [
"### Desafio 2\n",
"\n",
"Escreva uma função que receba um número inteiro de horas e converta esse número para segundos.\n",
"\n",
"Exemplo:\n",
"\n",
"convert(5) ➞ 18000\n",
"\n",
"convert(3) ➞ 10800\n",
"\n",
"convert(2) ➞ 7200"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "sSm6F7sff6JO"
},
"outputs": [
{
"data": {
"text/plain": [
"18000"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def convert_to_sec(number):\n",
" return number*3600\n",
"\n",
"convert_to_sec(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"include_colab_link": true,
"name": "Desafio 2.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
94 changes: 94 additions & 0 deletions Desafio_03_haisa.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"![](https://i.imgur.com/YX6UATs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "9apVxxygf6JR"
},
"source": [
"### Desafio 3\n",
"\n",
"Escreva uma função que receba uma lista como entrada e retorne uma nova lista ordenada e sem valores duplicados.\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "ndTkQEUBf6JS"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]\n"
]
}
],
"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\n",
"def organizar_lista(lista):\n",
" lista_unica = set(lista)\n",
" lista_ordenada = sorted(lista_unica)\n",
" return lista_ordenada\n",
"\n",
"print(organizar_lista(lista))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "wo2rA-NriFtO"
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"include_colab_link": true,
"name": "Desafio 3.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
96 changes: 96 additions & 0 deletions Desafio_04_haisa.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github"
},
"source": [
"![](https://i.imgur.com/YX6UATs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "dOqcKUYZf6JW"
},
"source": [
"### Desafio 4\n",
"\n",
"Escreva uma função cuja entrada é uma string e a saída é outra string com as palavras em ordem inversa.\n",
"\n",
"Exemplo:\n",
"\n",
"inverte_texto(\"Python é legal\") ➞ \"legal é Python\""
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "I5TInJDaf6JW"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"legal é Python\n"
]
}
],
"source": [
"# Seu código\n",
"frase = \"Python é legal\"\n",
"\n",
"def inverte_texto(str):\n",
" frase = str.split()\n",
" frase.reverse()\n",
" frase_inversa = \" \".join(frase)\n",
" return frase_inversa\n",
"\n",
"\n",
"frase_teste = inverte_texto(frase)\n",
"print(frase_teste)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"include_colab_link": true,
"name": "Desafio 4.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Loading