|
|
@ -59,7 +59,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.semi-opaque { |
|
|
|
.semi-opaque { |
|
|
|
background-color: rgba(0, 0, 0, 0.7); |
|
|
|
background-color: rgba(0, 0, 0, 0.8); |
|
|
|
color: #fff; |
|
|
|
color: #fff; |
|
|
|
text-shadow: 2px 2px #000; |
|
|
|
text-shadow: 2px 2px #000; |
|
|
|
} |
|
|
|
} |
|
|
@ -86,9 +86,8 @@ |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<ul class="empty"> |
|
|
|
<ul class="empty"> |
|
|
|
<li>Júlio Biason</li> |
|
|
|
<li>Júlio Biason</li> |
|
|
|
<li>@juliobiason</li> |
|
|
|
|
|
|
|
<li>https://functional.cafe/@juliobiason</li> |
|
|
|
<li>https://functional.cafe/@juliobiason</li> |
|
|
|
<li>julio.biason@gmail.com</li> |
|
|
|
<li>julio.biason@pm.me</li> |
|
|
|
<li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li> |
|
|
|
<li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li> |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -112,7 +111,7 @@ |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Solução</h2> |
|
|
|
<h2>Solução</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code>"""Randomize a "Run to the hills" phrase.""" |
|
|
|
<pre><code class="hljs python" data-trim>"""Randomize a "Run to the hills" phrase.""" |
|
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function |
|
|
|
from __future__ import print_function |
|
|
|
|
|
|
|
|
|
|
@ -178,7 +177,7 @@ if __name__ == "__main__": |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Docstrings</h2> |
|
|
|
<h2>Docstrings</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
"""Randomize a "Run to the hills" phrase.""" |
|
|
|
"""Randomize a "Run to the hills" phrase.""" |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -203,7 +202,7 @@ if __name__ == "__main__": |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Módulos e imports</h2> |
|
|
|
<h2>Módulos e imports</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
import random |
|
|
|
import random |
|
|
|
from argparse import ArgumentParser |
|
|
|
from argparse import ArgumentParser |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -267,7 +266,7 @@ from argparse import ArgumentParser |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Variáveis e tipos</h2> |
|
|
|
<h2>Variáveis e tipos</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -292,13 +291,25 @@ PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
nós vamos estragar essa convenção.) |
|
|
|
nós vamos estragar essa convenção.) |
|
|
|
</aside> |
|
|
|
</aside> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h2>Variáveis e tipos (um pouco mais)</h2> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul> |
|
|
|
|
|
|
|
<li><code>" ou '</code>: Strings</li> |
|
|
|
|
|
|
|
<li><code>[]</code>: Listas/arrays</li> |
|
|
|
|
|
|
|
<li><code>{}</code>: Dicionários/mapas/objetos/arrays associativos</li> |
|
|
|
|
|
|
|
<li><code>()</code>: Tuplas</li> |
|
|
|
|
|
|
|
<li><code>Set()</code>: Conjuntos (tipo lista, sem duplicações)</li> |
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def print_phrase(consonants): |
|
|
|
def print_phrase(consonants): |
|
|
|
"""Print the phrase with the randomized consonants.""" |
|
|
|
"""Print the phrase with the randomized consonants.""" |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -328,7 +339,7 @@ def print_phrase(consonants): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def print_phrase(consonants, something_else): |
|
|
|
def print_phrase(consonants, something_else): |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -341,7 +352,7 @@ def print_phrase(consonants, something_else): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funcões</h2> |
|
|
|
<h2>Funcões</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(primeiro, segundo): |
|
|
|
def soma(primeiro, segundo): |
|
|
|
total = primeiro + segundo |
|
|
|
total = primeiro + segundo |
|
|
|
return total |
|
|
|
return total |
|
|
@ -361,7 +372,7 @@ def soma(primeiro, segundo): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(1, 2) |
|
|
|
soma(1, 2) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -374,7 +385,7 @@ soma(1, 2) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(primeiro=2, segundo=3) |
|
|
|
soma(primeiro=2, segundo=3) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -387,7 +398,7 @@ soma(primeiro=2, segundo=3) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(segundo=3, primeiro=2) |
|
|
|
soma(segundo=3, primeiro=2) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -404,11 +415,11 @@ soma(segundo=3, primeiro=2) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções</h2> |
|
|
|
<h2>Funções</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(primeiro=0, segundo=0): |
|
|
|
def soma(primeiro=0, segundo=0): |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma() |
|
|
|
soma() |
|
|
|
soma(1) |
|
|
|
soma(1) |
|
|
|
soma(segundo=3) |
|
|
|
soma(segundo=3) |
|
|
@ -428,17 +439,17 @@ soma(segundo=3) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(primeiro, segundo): |
|
|
|
def soma(primeiro, segundo): |
|
|
|
total = primeiro + segundo |
|
|
|
total = primeiro + segundo |
|
|
|
return total |
|
|
|
return total |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code> |
|
|
|
<pre class="fragment"><code class="hljs python" data-trim> |
|
|
|
soma(1) |
|
|
|
soma(1) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code> |
|
|
|
<pre class="fragment"><code class="hljs python" data-trim> |
|
|
|
soma(1, 2, 3) |
|
|
|
soma(1, 2, 3) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -451,7 +462,7 @@ soma(1, 2, 3) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
TypeError: soma() takes exactly 2 arguments (3 given) |
|
|
|
TypeError: soma() takes exactly 2 arguments (3 given) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -464,7 +475,7 @@ TypeError: soma() takes exactly 2 arguments (3 given) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(*valores): |
|
|
|
def soma(*valores): |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -479,16 +490,16 @@ def soma(*valores): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(*valores): |
|
|
|
def soma(*valores): |
|
|
|
print(valores) |
|
|
|
print(valores) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(1, 2, 3, 4, 5) |
|
|
|
soma(1, 2, 3, 4, 5) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code> |
|
|
|
<pre class="fragment"><code class="hljs python" data-trim> |
|
|
|
[1, 2, 3, 4, 5] |
|
|
|
[1, 2, 3, 4, 5] |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
</section> |
|
|
|
</section> |
|
|
@ -496,7 +507,7 @@ soma(1, 2, 3, 4, 5) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(inicial, segundo=0, *valores): |
|
|
|
def soma(inicial, segundo=0, *valores): |
|
|
|
print(inicial) |
|
|
|
print(inicial) |
|
|
|
print(segundo) |
|
|
|
print(segundo) |
|
|
@ -504,11 +515,11 @@ def soma(inicial, segundo=0, *valores): |
|
|
|
|
|
|
|
|
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(2) |
|
|
|
soma(2) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
2 |
|
|
|
2 |
|
|
|
0 |
|
|
|
0 |
|
|
|
[] |
|
|
|
[] |
|
|
@ -526,16 +537,16 @@ soma(2) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def soma(**valores): |
|
|
|
def soma(**valores): |
|
|
|
print(valores) |
|
|
|
print(valores) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
soma(primeiro=1, segundo=2) |
|
|
|
soma(primeiro=1, segundo=2) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
{'primeiro': 1, 'segundo': 2} |
|
|
|
{'primeiro': 1, 'segundo': 2} |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -568,7 +579,7 @@ soma(primeiro=1, segundo=2) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
<h2>Pausa: Varargs</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
params = [4, 4] |
|
|
|
params = [4, 4] |
|
|
|
soma(*params) |
|
|
|
soma(*params) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -594,7 +605,7 @@ soma(*params) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
"isso é uma string" |
|
|
|
"isso é uma string" |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -606,7 +617,7 @@ soma(*params) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
help("isso é uma string") |
|
|
|
help("isso é uma string") |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -625,11 +636,11 @@ help("isso é uma string") |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
<h2>Pausa: Objetos</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
"isso é uma string".capitalize() |
|
|
|
"isso é uma string".capitalize() |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
frase = "isso é uma string" |
|
|
|
frase = "isso é uma string" |
|
|
|
frase.capitalize() |
|
|
|
frase.capitalize() |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -640,7 +651,7 @@ frase.capitalize() |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2><span style="color:crimson">Welcome to Hell</span></h2> |
|
|
|
<h2><span style="color:crimson">Welcome to Hell</span></h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
print(PASSPHRASE.format(*consonants).capitalize()) |
|
|
|
print(PASSPHRASE.format(*consonants).capitalize()) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -680,11 +691,11 @@ frase.capitalize() |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2><span style="color:crimson">Welcome</span> to Hell</h2> |
|
|
|
<h2><span style="color:crimson">Welcome</span> to Hell</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
'Bem vindo {}!'.format('Júlio') |
|
|
|
'Bem vindo {}!'.format('Júlio') |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
Bem vindo Júlio! |
|
|
|
Bem vindo Júlio! |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -697,12 +708,12 @@ Bem vindo Júlio! |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to Hell</h2> |
|
|
|
<h2>Welcome to Hell</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
PASSPHRASE.format('f', 'j', 'c', 'l', 'n') |
|
|
|
PASSPHRASE.format('f', 'j', 'c', 'l', 'n') |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code> |
|
|
|
<pre class="fragment"><code class="hljs python" data-trim> |
|
|
|
'fujam para as colinas' |
|
|
|
'fujam para as colinas' |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -716,13 +727,13 @@ PASSPHRASE.format('f', 'j', 'c', 'l', 'n') |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to... Hell</h2> |
|
|
|
<h2>Welcome to... Hell</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
PASSPHRASE = '{}u{}am para as {}o{}i{}as' |
|
|
|
PASSPHRASE.format(*CONSONANTS) |
|
|
|
PASSPHRASE.format(*CONSONANTS) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
'fujam para as colinas' |
|
|
|
'fujam para as colinas' |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -737,11 +748,11 @@ PASSPHRASE.format(*CONSONANTS) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to... Hell?</h2> |
|
|
|
<h2>Welcome to... Hell?</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
'fujam para as colinas'.capitalize() |
|
|
|
'fujam para as colinas'.capitalize() |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
Fujam para as colinas |
|
|
|
Fujam para as colinas |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -756,7 +767,7 @@ Fujam para as colinas |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Randomizações</h2> |
|
|
|
<h2>Randomizações</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def totally_random(): |
|
|
|
def totally_random(): |
|
|
|
"""Run a totally random way.""" |
|
|
|
"""Run a totally random way.""" |
|
|
|
random.shuffle(CONSONANTS) |
|
|
|
random.shuffle(CONSONANTS) |
|
|
@ -776,7 +787,7 @@ def totally_random(): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Randomizações</h2> |
|
|
|
<h2>Randomizações</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
def switch_two(): |
|
|
|
def switch_two(): |
|
|
|
"""Run by changing two steps at a time.""" |
|
|
|
"""Run by changing two steps at a time.""" |
|
|
|
first = random.randint(0, 1) |
|
|
|
first = random.randint(0, 1) |
|
|
@ -801,7 +812,7 @@ def switch_two(): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to hell, maybe?</h2> |
|
|
|
<h2>Welcome to hell, maybe?</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
CONSONANTS[second], CONSONANTS[first] = \ |
|
|
|
CONSONANTS[second], CONSONANTS[first] = \ |
|
|
|
CONSONANTS[first], CONSONANTS[second] |
|
|
|
CONSONANTS[first], CONSONANTS[second] |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -810,7 +821,7 @@ def switch_two(): |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to Listas!</h2> |
|
|
|
<h2>Welcome to Listas!</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
# CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
# CONSONANTS = ['f', 'j', 'c', 'l', 'n'] |
|
|
|
# second = random.randint(2, 4) |
|
|
|
# second = random.randint(2, 4) |
|
|
|
CONSONANTS[second] |
|
|
|
CONSONANTS[second] |
|
|
@ -836,7 +847,7 @@ CONSONANTS[second] |
|
|
|
E pra criar uma tupla: |
|
|
|
E pra criar uma tupla: |
|
|
|
</p> |
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
valor, valor |
|
|
|
valor, valor |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -846,13 +857,13 @@ valor, valor |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Welcome to Destructuring</h2> |
|
|
|
<h2>Welcome to Destructuring</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
primeiro, segundo = [1, 2] |
|
|
|
primeiro, segundo = [1, 2] |
|
|
|
print(primeiro) |
|
|
|
print(primeiro) |
|
|
|
print(segundo) |
|
|
|
print(segundo) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
1 |
|
|
|
1 |
|
|
|
2 |
|
|
|
2 |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
@ -875,12 +886,12 @@ print(segundo) |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Tudo junto, agora!</h2> |
|
|
|
<h2>Tudo junto, agora!</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
CONSONANTS[second], CONSONANTS[first] = \ |
|
|
|
CONSONANTS[second], CONSONANTS[first] = \ |
|
|
|
CONSONANTS[first], CONSONANTS[second] |
|
|
|
CONSONANTS[first], CONSONANTS[second] |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
<pre class="fragment"><code> |
|
|
|
<pre class="fragment"><code class="hljs python" data-trim> |
|
|
|
tmp = CONSONANTS[first] |
|
|
|
tmp = CONSONANTS[first] |
|
|
|
CONSONANTS[first] = CONSONANTS[second] |
|
|
|
CONSONANTS[first] = CONSONANTS[second] |
|
|
|
CONSONANTS[second] = tmp |
|
|
|
CONSONANTS[second] = tmp |
|
|
@ -901,7 +912,7 @@ CONSONANTS[second] = tmp |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>O Pai de Todos Módulos</h2> |
|
|
|
<h2>O Pai de Todos Módulos</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
@ -937,7 +948,7 @@ if __name__ == "__main__": |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>A linha de comando</h2> |
|
|
|
<h2>A linha de comando</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
args = ArgumentParser() |
|
|
|
args = ArgumentParser() |
|
|
|
args.add_argument('-t', '--totally', |
|
|
|
args.add_argument('-t', '--totally', |
|
|
|
dest='type', |
|
|
|
dest='type', |
|
|
@ -967,7 +978,7 @@ if __name__ == "__main__": |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h2>Funções são cidadãos de primeira classe</h2> |
|
|
|
<h2>Funções são cidadãos de primeira classe</h2> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code> |
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
callbacks = { |
|
|
|
callbacks = { |
|
|
|
'totally': totally_random, |
|
|
|
'totally': totally_random, |
|
|
|
'switch': switch_two |
|
|
|
'switch': switch_two |
|
|
@ -1010,6 +1021,46 @@ if __name__ == "__main__": |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h2>O que faltou?</h2> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h3>List comprehensions</h3> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
|
|
|
|
numeros = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
|
|
|
|
|
|
pares = [num |
|
|
|
|
|
|
|
for num |
|
|
|
|
|
|
|
in numeros |
|
|
|
|
|
|
|
if num % 2 = 0] |
|
|
|
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p class="fragment">Curiosidade: Strings são iteráveis como listas.</p> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h3>Generators</h3> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="hljs python" data-trim> |
|
|
|
|
|
|
|
numeros = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
|
|
|
|
|
|
|
pares = (num |
|
|
|
|
|
|
|
for num |
|
|
|
|
|
|
|
in numeros |
|
|
|
|
|
|
|
if num % 2 = 0) |
|
|
|
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="hljs python fragment" data-trim> |
|
|
|
|
|
|
|
<generator object <genexpr> at 0x7f03ce4e67d0> |
|
|
|
|
|
|
|
</code></pre> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
|
|
|
|
<h3>Laziness</h3> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<section data-background="_images/python.jpg"> |
|
|
|
<section data-background="_images/python.jpg"> |
|
|
|
<h1 class="semi-opaque">Fulindo para as Cojinas com Python</h1> |
|
|
|
<h1 class="semi-opaque">Fulindo para as Cojinas com Python</h1> |
|
|
@ -1022,16 +1073,18 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
|
|
<section data-background='_images/thats-all-folks.jpg'> |
|
|
|
<section data-background='_images/thats-all-folks.jpg'> |
|
|
|
<section> |
|
|
|
<section> |
|
|
|
<h1 class="fragment semi-opaque">Perguntas?</h1> |
|
|
|
<div class="semi-opaque"> |
|
|
|
|
|
|
|
<ul class="empty"> |
|
|
|
<div class="fragment semi-opaque"> |
|
|
|
<li>Júlio Biason</li> |
|
|
|
<ul> |
|
|
|
|
|
|
|
<li>@juliobiason</li> |
|
|
|
|
|
|
|
<li>https://functional.cafe/@juliobiason</li> |
|
|
|
<li>https://functional.cafe/@juliobiason</li> |
|
|
|
<li>julio.biason@gmail.com</li> |
|
|
|
<li>julio.biason@pm.me</li> |
|
|
|
<li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li> |
|
|
|
<li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li> |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3></h3> <!-- this is stupid, but I'm not in the mood to figure out the proper CSS --> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1 class="fragment semi-opaque">Perguntas?</h1> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|