Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adicionado coisas Aulas 1 a 3 #12

Merged
merged 1 commit into from
Sep 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
145 changes: 116 additions & 29 deletions notebooks/Aula_1_Operadores_Aritmeticos_Relacionais_e_Logicos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,89 @@
"text": [
"<class 'str'>\n",
"Número de caracteres do logo: 9\n",
"Bem-vindo à UNINOVE, o seu professor é José Eduardo Storopoli\n"
"Bem-vindo à UNINOVE, o seu professor é Duda e Edson\n"
]
}
],
"source": [
"universidade = 'UNINOVE'\n",
"logo = 'uni9 é 10'\n",
"professor = 'José Eduardo Storopoli'\n",
"professor = \"Duda e Edson\" # usando aspas duplas \"\n",
"\n",
"print(type(logo))\n",
"print('Número de caracteres do logo: ', len(logo)) # usando ,\n",
"print('Bem-vindo à ' + universidade +\n",
" ', o seu professor é ' + professor) # usando +"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### `fstrings`\n",
"\n",
"As `fstrings` foram introduzidas em Python versão 3.6 e são uma forma conveniente de nos fazermos substituição de _placeholders_ em uma string por variáveis ou expressões:\n",
"\n",
"Funciona assim:\n",
"\n",
"```python\n",
"f\"Aqui é uma string com uma {var}\"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Bem-vindo à UNINOVE. Seus professores são Duda e Edson.\n",
"<class 'str'>\n"
]
}
],
"source": [
"fstring = f\"Bem-vindo à UNINOVE. Seus professores são {professor}.\"\n",
"print(fstring)\n",
"print(type(fstring))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'2 + 2 = 4'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# também funciona para expressões\n",
"f\"2 + 2 = {2+2}\""
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -159,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {
"scrolled": true,
"slideshow": {
Expand All @@ -177,12 +245,41 @@
}
],
"source": [
"mortalidade = True\n",
"mortalidade = True # cuidado com o TitleCase true != True\n",
"\n",
"print(mortalidade)\n",
"print(type(mortalidade))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"#### Não temos os *parkour* de JavaScript\n",
"\n",
"`str` + `int` dá um erro:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"# o código abaixo dá um erro\n",
"#\"3\" + 1\n",
"\n",
"# TypeError: can only concatenate str (not \"int\") to str"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -198,7 +295,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {
"scrolled": true,
"slideshow": {
Expand All @@ -211,9 +308,9 @@
"output_type": "stream",
"text": [
"dados do aluno\n",
"informe seu nome: Edson Melo\n",
"informe sua idade: 50\n",
"Edson Melo você tem 50 anos!\n"
"informe seu nome: Duda\n",
"informe sua idade: 33\n",
"Duda você tem 33 anos!\n"
]
}
],
Expand Down Expand Up @@ -247,7 +344,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {
"scrolled": true,
"slideshow": {
Expand Down Expand Up @@ -307,7 +404,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {
"scrolled": true,
"slideshow": {
Expand All @@ -328,7 +425,7 @@
],
"source": [
"import math\n",
"#import math as m \n",
"#import math as m\n",
"#from math import floor, ceil\n",
"\n",
"print('Arredondamento simples:', round(3.33))\n",
Expand Down Expand Up @@ -358,7 +455,7 @@
}
},
"source": [
"* Igual a: `x == y`\n",
"* Igual a: `x == y` (não existe `x === y`)\n",
"* Maior que: `x > y`\n",
"* Menor que: `x < y`\n",
"* Maior ou igual a: `x >= y`\n",
Expand All @@ -368,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {
"scrolled": true,
"slideshow": {
Expand Down Expand Up @@ -421,33 +518,23 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"scrolled": true,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"True\n",
"False\n"
]
}
],
"outputs": [],
"source": [
"x = 1\n",
"y = 3\n",
"z = 5\n",
"w = 2\n",
"\n",
"print(z > w and w > y) # False\n",
"print(z > w or w > y) # True\n",
"print(not y + w == z) # False"
"print((z > w) and (w > y)) # False\n",
"print((z > w) or (w > y)) # True\n",
"print(not (y + w == z)) # False"
]
},
{
Expand Down Expand Up @@ -566,7 +653,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
"version": "3.9.6"
},
"rise": {
"autolaunch": true,
Expand Down
44 changes: 22 additions & 22 deletions notebooks/Aula_2_Desvio_Condicional_IF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
"b = 5\n",
"c = 0\n",
"\n",
"if (a == b):\n",
"if a == b:\n",
" print('a é igual a b')\n",
" c +=2\n",
" c += 2\n",
"print('Valor de c: ', c)"
]
},
Expand All @@ -111,7 +111,7 @@
"a = 5\n",
"b = 5\n",
"c = 0\n",
"if (a != b):\n",
"if a != b:\n",
" print('a é diferente de b')\n",
" c +=2\n",
"print('Valor de c: ', c)"
Expand Down Expand Up @@ -141,9 +141,9 @@
"b = 5\n",
"c = 0\n",
"\n",
"if (a == b):\n",
"if a == b:\n",
" print('a é igual a b')\n",
" if (c + 5 == a):\n",
" if c + 5 == a:\n",
" print('c mais cinco é igual a a')\n",
" c += 2\n",
" c +=2\n",
Expand Down Expand Up @@ -173,9 +173,9 @@
"b = 5\n",
"c = 0\n",
"\n",
"if (a == b):\n",
"if a == b:\n",
" print('a é igual a b')\n",
" if (c + 6 == a):\n",
" if c + 6 == a:\n",
" print('c mais seis é igual a a')\n",
" c += 2\n",
" c +=2\n",
Expand Down Expand Up @@ -204,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "subslide"
Expand All @@ -226,9 +226,9 @@
"b = 5\n",
"c = 0\n",
"\n",
"if (a == b):\n",
"if a == b:\n",
" print('a é igual a b')\n",
" if (c + 5 == a):\n",
" if c + 5 == a:\n",
" print('c mais cinco é igual a a')\n",
" c += 2\n",
"else:\n",
Expand All @@ -238,7 +238,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "fragment"
Expand All @@ -258,9 +258,9 @@
"b = 5\n",
"c = 0\n",
"\n",
"if (a != b):\n",
"if a != b:\n",
" print('a é diferente de b')\n",
" if (c + 6 == a):\n",
" if c + 6 == a:\n",
" print('c mais seis é igual a a')\n",
" c += 2\n",
"else:\n",
Expand Down Expand Up @@ -305,7 +305,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {
"slideshow": {
"slide_type": "subslide"
Expand All @@ -317,24 +317,24 @@
"output_type": "stream",
"text": [
"informe valor de a: \n",
"2\n",
"11\n"
"4\n",
"13\n"
]
}
],
"source": [
"c = 0\n",
"a = int(input(\"informe valor de a: \\n\"))\n",
"\n",
"if (a==1):\n",
"if a==1:\n",
" c = 10\n",
"elif (a==2):\n",
"elif a==2:\n",
" c = 11\n",
"elif (a==3):\n",
"elif a==3:\n",
" c = 12\n",
"elif (a==4):\n",
"elif a==4:\n",
" c = 13\n",
"elif (a==5):\n",
"elif a==5:\n",
" c = 14\n",
"else:\n",
" c = 20\n",
Expand Down Expand Up @@ -432,7 +432,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
"version": "3.9.6"
},
"rise": {
"autolaunch": true,
Expand Down