Skip to content
Open
154 changes: 154 additions & 0 deletions Desafio_01_Fernando_Krum_DS38.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ferkrum/DS-Notebooks-br-python-challenges/blob/master/Desafio_01_Fernando_Krum_DS38.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"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": 1,
"metadata": {
"id": "WhtbdwFseldD"
},
"outputs": [],
"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",
"\n",
"# Seu código"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"id": "M58o1U9KfAxa"
},
"outputs": [],
"source": [
"qtdadeTotal = len(palavras)"
]
},
{
"cell_type": "code",
"source": [
"#modelo para contagem de palavras:\n",
"palavras.count('red')"
],
"metadata": {
"id": "CWEFRp2Bacqe",
"outputId": "5775650d-d856-4fc4-802c-44f5abb9a698",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"4"
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"source": [
"contagemPalavras = {} #inicia dicionario para armazenar contagem de palavras\n",
"for palavra in palavras:\n",
" contagemPalavras[palavra] = palavras.count(palavra)\n"
],
"metadata": {
"id": "06kpQDxRawSC"
},
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"source": [
"contagemPalavras"
],
"metadata": {
"id": "gQ8P2xvIcN90",
"outputId": "89453f9a-d92e-45cf-fcc8-33879d663a30",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'black': 5,\n",
" 'eyes': 1,\n",
" 'green': 4,\n",
" 'orange': 4,\n",
" 'pink': 6,\n",
" 'red': 4,\n",
" 'white': 5}"
]
},
"metadata": {},
"execution_count": 10
}
]
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"name": "Desafio 1.ipynb",
"provenance": [],
"include_colab_link": true
},
"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.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
81 changes: 81 additions & 0 deletions Desafio_02_Fernando_Krum_DS38.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ferkrum/DS-Notebooks-br-python-challenges/blob/master/Desafio_02_Fernando_Krum_DS38.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "A1DyFQAkcivd"
},
"source": [
"![](https://i.imgur.com/YX6UATs.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"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": null,
"metadata": {
"id": "sSm6F7sff6JO"
},
"outputs": [],
"source": [
"def convert_to_sec(number):\n",
" return number * 60 * 60"
]
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"name": "Desafio 2.ipynb",
"provenance": [],
"include_colab_link": true
},
"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.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
132 changes: 132 additions & 0 deletions Desafio_03_Fernando_Krum_DS38.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/ferkrum/DS-Notebooks-br-python-challenges/blob/master/Desafio_03_Fernando_Krum_DS38.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"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": 30,
"metadata": {
"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"
]
},
{
"cell_type": "code",
"source": [
"lista.sort()\n",
"lista"
],
"metadata": {
"id": "y-Gazedrd2xD",
"outputId": "437c9f0b-bf8f-4eae-9d0a-d752ffa38366",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 31,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 9, 13, 15, 30, 45]"
]
},
"metadata": {},
"execution_count": 31
}
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"id": "wo2rA-NriFtO"
},
"outputs": [],
"source": [
"def NovaLista(lista):\n",
" lista_nova = []\n",
" for i in lista:\n",
" if not(i in lista_nova):\n",
" lista_nova.append(i)\n",
"\n",
" print(lista_nova)"
]
},
{
"cell_type": "code",
"source": [
"NovaLista(lista)"
],
"metadata": {
"id": "OmY2A_iLfeGs",
"outputId": "1494fea5-1222-4928-d246-ca339714a023",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 37,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[1, 2, 3, 4, 5, 6, 9, 13, 15, 30, 45]\n"
]
}
]
}
],
"metadata": {
"anaconda-cloud": {},
"colab": {
"name": "Desafio 3.ipynb",
"provenance": [],
"include_colab_link": true
},
"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.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading