<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Programe em Python</title><link href="http://programeempython.com.br/" rel="alternate"></link><link href="http://programeempython.com.br/feeds/all.atom.xml" rel="self"></link><id>http://programeempython.com.br/</id><updated>2022-08-30T00:06:00+02:00</updated><entry><title>Python 101 - Parte 10 - Estruturas de Dados - Dicionários</title><link href="http://programeempython.com.br/python-101-parte-10.html" rel="alternate"></link><published>2022-08-30T00:06:00+02:00</published><updated>2022-08-30T00:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-30:/python-101-parte-10.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hoje vamos falar de uma estrutura de dados que n&amp;atilde;o est&amp;aacute; presente em todas as linguagens. Esta estrutura &amp;eacute; chamada de&amp;nbsp;dicion&amp;aacute;rio.&lt;/p&gt;
&lt;p&gt;Os dicion&amp;aacute;rios em Python s&amp;atilde;o estruturas de dados que cont&amp;eacute;m pares de&amp;nbsp;chave-valor.&lt;/p&gt;
&lt;p&gt;S&amp;atilde;o parecidos com as listas, considerando que ambos s&amp;atilde;o sequencias de elementos, mas o …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hoje vamos falar de uma estrutura de dados que n&amp;atilde;o est&amp;aacute; presente em todas as linguagens. Esta estrutura &amp;eacute; chamada de&amp;nbsp;dicion&amp;aacute;rio.&lt;/p&gt;
&lt;p&gt;Os dicion&amp;aacute;rios em Python s&amp;atilde;o estruturas de dados que cont&amp;eacute;m pares de&amp;nbsp;chave-valor.&lt;/p&gt;
&lt;p&gt;S&amp;atilde;o parecidos com as listas, considerando que ambos s&amp;atilde;o sequencias de elementos, mas o acesso a cada posi&amp;ccedil;&amp;atilde;o da lista &amp;eacute; feito de forma&amp;nbsp;diferente.&lt;/p&gt;
&lt;p&gt;Caso voc&amp;ecirc; ainda n&amp;atilde;o tenha visto os outros artigos da s&amp;eacute;rie Python 101, aqui&amp;nbsp;est&amp;atilde;o:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7.html"&gt;Estruturas de Dados do Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-8.html"&gt;Estruturas de Dados do Python -&amp;nbsp;Listas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-9.html"&gt;Estruturas de Dados do Python - Lista&amp;nbsp;Comprehentions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vejamos ent&amp;atilde;o como trabalhar com Dicion&amp;aacute;rios em&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;Para come&amp;ccedil;ar, vamos ver as maneiras de definir um&amp;nbsp;dicion&amp;aacute;rio.&lt;/p&gt;
&lt;p&gt;Primeiro definimos um dicion&amp;aacute;rio&amp;nbsp;vazio:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;dicionario&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Este dicion&amp;aacute;rio pode receber valores futuramente durante a execu&amp;ccedil;&amp;atilde;o do&amp;nbsp;programa.&lt;/p&gt;
&lt;p&gt;Agora, imaginemos como seria montar um dicion&amp;aacute;rio que relacionasse strings para os dias da semana, como &amp;lsquo;seg&amp;rsquo; e &amp;lsquo;ter&amp;rsquo; com n&amp;uacute;meros. Indispens&amp;aacute;vel se voc&amp;ecirc; for fazer um calend&amp;aacute;rio, n&amp;atilde;o&amp;nbsp;acha?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;dias_semana&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'dom'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'seg'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ter'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'qua'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'qui'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sex'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sab'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Ao criarmos um dicion&amp;aacute;rio, ele ter&amp;aacute; esta estrutura. Antes do &amp;lsquo;:&amp;rsquo; temos a chave do par chave-valor, e logo ap&amp;oacute;s, o valor&amp;nbsp;correspondente.&lt;/p&gt;
&lt;p&gt;Mas, e se f&amp;ocirc;ssemos criar um dicion&amp;aacute;rio que relacionasse as letras N, L, S, O dos pontos cardeais com&amp;nbsp;n&amp;uacute;meros?&lt;/p&gt;
&lt;p&gt;Aposto que voc&amp;ecirc; j&amp;aacute; sabe a resposta! Mas, existe uma outra forma, tamb&amp;eacute;m muito &amp;uacute;til de gerar dicion&amp;aacute;rios, e que pode ser muito importante para gera&amp;ccedil;&amp;atilde;o destes dicion&amp;aacute;rios em tempo de&amp;nbsp;execu&amp;ccedil;&amp;atilde;o.&lt;/p&gt;
&lt;p&gt;Usando &lt;code&gt;dict()&lt;/code&gt; podemos transformar listas de tuplas em dicion&amp;aacute;rios. Tecnicamente seriam sequencias de sequencias, mas para o exemplo vamos usar listas de&amp;nbsp;tuplas.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Se voc&amp;ecirc; n&amp;atilde;o lembra o que &amp;eacute; uma tupla, confira nosso &lt;a href="http://programeempython.com.br/python-101-parte-7.html"&gt;post de introdu&amp;ccedil;&amp;atilde;o &amp;agrave;s estruturas de&amp;nbsp;dados&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Veja como funciona o &lt;code&gt;dict()&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;pontos_cardeais&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="s1"&gt;'N'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'L'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'S'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'O'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Voc&amp;ecirc; se lembra da &lt;a href="http://programeempython.com.br/python-101-parte-9.html"&gt;List Comprehension&lt;/a&gt; que vimos no &amp;uacute;ltimo&amp;nbsp;post?&lt;/p&gt;
&lt;p&gt;Pois bem, que tal us&amp;aacute;-la para montar um dicion&amp;aacute;rio que relaciona os inteiros de zero a dez e seus respectivos&amp;nbsp;quadrados?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;quadrados&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&amp;Eacute; muito simples criar dicion&amp;aacute;rio,&amp;nbsp;n&amp;atilde;o?&lt;/p&gt;
&lt;p&gt;Mas&amp;hellip; simplesmente criar os dicion&amp;aacute;rios n&amp;atilde;o tem utilidade nenhuma,&amp;nbsp;certo?&lt;/p&gt;
&lt;p&gt;Vejamos como acessar um valor a partir de sua chave. vamos usar o dicion&amp;aacute;rio dos dias da semana. Experimente os comandos no Shell do&amp;nbsp;Python!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; dias_semana['ter']
2
&amp;gt;&amp;gt;&amp;gt; dias_semana['sab']
6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;F&amp;aacute;cil, n&amp;atilde;o&amp;nbsp;&amp;eacute;?&lt;/p&gt;
&lt;p&gt;Vamos inserir alguns valores neste&amp;nbsp;dicion&amp;aacute;rio?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; dias_semana
{'qua': 3, 'dom': 0, 'sab': 6, 'sex': 5, 'seg': 1, 'qui': 4, 'ter': 2}
&amp;gt;&amp;gt;&amp;gt; dias_semana['Dom'] = 0
&amp;gt;&amp;gt;&amp;gt; dias_semana['Seg'] = 1
&amp;gt;&amp;gt;&amp;gt; dias_semana['Ter'] = 2
&amp;gt;&amp;gt;&amp;gt; dias_semana['Qua'] = 3
&amp;gt;&amp;gt;&amp;gt; dias_semana['Qui'] = 4
&amp;gt;&amp;gt;&amp;gt; dias_semana['Sex'] = 5
&amp;gt;&amp;gt;&amp;gt; dias_semana['Sab'] = 6
&amp;gt;&amp;gt;&amp;gt; dias_semana
{'qua': 3, 'dom': 0, 'sab': 6, 'Dom': 0, 'Seg': 1, 'sex': 5, 'seg': 1, 
'Qui': 4, 'Qua': 3, 'Sab': 6, 'qui': 4, 'ter': 2, 'Sex': 5, 'Ter': 2}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Num dicion&amp;aacute;rio, a ordem em que os elementos aparecem n&amp;atilde;o &amp;eacute; t&amp;atilde;o importante, pois os valores s&amp;atilde;o acessados principalmente atrav&amp;eacute;s de suas respectivas chaves, e n&amp;atilde;o de suas posi&amp;ccedil;&amp;otilde;es. Al&amp;eacute;m disso, dicion&amp;aacute;rios n&amp;atilde;o guardam a ordem dos elementos, logo, o elemento que aparece em primeiro lugar numa execu&amp;ccedil;&amp;atilde;o pode n&amp;atilde;o ser o primeiro em outra mesmo que a inser&amp;ccedil;&amp;atilde;o tenha sido feita da mesma&amp;nbsp;forma.&lt;/p&gt;
&lt;p&gt;Caso seja necess&amp;aacute;rio verificar se uma chave j&amp;aacute; se encontra no dicion&amp;aacute;rio, basta fazer o&amp;nbsp;seguinte&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 'seg' in dias_semana
True
&amp;gt;&amp;gt;&amp;gt; 'bla' in dias_semana
False
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Bem, digamos agora que n&amp;atilde;o quero mais que o dicion&amp;aacute;rio tenha a vers&amp;atilde;o mai&amp;uacute;scula para o&amp;nbsp;domingo.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; del(dias_semana['Dom])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Tamb&amp;eacute;m &amp;eacute; poss&amp;iacute;vel saber quais as chaves que j&amp;aacute; foram&amp;nbsp;inseridas:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; dias_semana.keys()
['sab', 'seg', 'sex', 'qua', 'qui', 'ter', 'Qua', 'dom', 'Sab', 'Sex',
'Seg', 'Qui', 'Ter']
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;E quais os valores que h&amp;aacute; no dicion&amp;aacute;rio:
    &amp;gt;&amp;gt;&amp;gt; dias_semana.values()
    [6, 1, 5, 3, 4, 2, 3, 0, 6, 5, 1, 4,&amp;nbsp;2]&lt;/p&gt;
&lt;p&gt;Algo importante a se notar &amp;eacute; que as chaves e elementos de dicion&amp;aacute;rios podem ser de virtualmente qualquer tipo, com exce&amp;ccedil;&amp;atilde;o das chaves que tem uma restri&amp;ccedil;&amp;atilde;o. Os objetos tem que ser&amp;nbsp;imut&amp;aacute;veis.&lt;/p&gt;
&lt;p&gt;Isto quer dizer que a lista &lt;code&gt;[1, 2, 3]&lt;/code&gt; n&amp;atilde;o pode ser uma chave de dicion&amp;aacute;rio j&amp;aacute; que podemos no meio da execu&amp;ccedil;&amp;atilde;o alterar valores da lista. J&amp;aacute; a tupla &lt;code&gt;(1, 2, 3)&lt;/code&gt; que &amp;eacute; imut&amp;aacute;vel pode ser uma chave de dicion&amp;aacute;rios sem&amp;nbsp;problemas.&lt;/p&gt;
&lt;p&gt;Agora, voc&amp;ecirc; j&amp;aacute; conhece os Dicion&amp;aacute;rios do Python, esta estrutura de dados que tem tantas aplica&amp;ccedil;&amp;otilde;es&amp;nbsp;importantes.&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 10 - Data Structures - Dictionaries</title><link href="http://programeempython.com.br/python-101-parte-10-en.html" rel="alternate"></link><published>2022-08-30T00:06:00+02:00</published><updated>2022-08-30T00:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-30:/python-101-parte-10-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today we are going to talk about a data structure that is not present in all languages. This structure is called a&amp;nbsp;dictionary.&lt;/p&gt;
&lt;p&gt;Python dictionaries are data structures that contain key-value&amp;nbsp;pairs.&lt;/p&gt;
&lt;p&gt;They are similar to lists, considering that both are sequences of elements, but accessing each position in …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today we are going to talk about a data structure that is not present in all languages. This structure is called a&amp;nbsp;dictionary.&lt;/p&gt;
&lt;p&gt;Python dictionaries are data structures that contain key-value&amp;nbsp;pairs.&lt;/p&gt;
&lt;p&gt;They are similar to lists, considering that both are sequences of elements, but accessing each position in the list is done&amp;nbsp;differently.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the other articles in the Python 101 series, here they&amp;nbsp;are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repeat Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repeat Structures -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7-en.html"&gt;Python Data Structures -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-8-en.html"&gt;Python Data Structures -&amp;nbsp;Lists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-9-en.html"&gt;Python Data Structures - Comprehentions&amp;nbsp;List&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So let&amp;rsquo;s see how to work with Dictionaries in&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;To get started, let&amp;rsquo;s look at ways to define a&amp;nbsp;dictionary.&lt;/p&gt;
&lt;p&gt;First we define an empty&amp;nbsp;dictionary:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;dictionary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;This dictionary can receive values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;in the future during the execution of the&amp;nbsp;program.&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s imagine what it would be like to build a dictionary that listed strings for the days of the week, such as &amp;lsquo;mon&amp;rsquo; and &amp;lsquo;ter&amp;rsquo; with numbers. Indispensable if you&amp;rsquo;re going to make a calendar, don&amp;rsquo;t you&amp;nbsp;think?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;weekdays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'sun'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'mon'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tue'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wed'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'thu'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sex'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sat'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;When we create a dictionary, it will have this structure. Before the &lt;code&gt;:&lt;/code&gt; we have the key of the key-value pair, and after that, the corresponding&amp;nbsp;value.&lt;/p&gt;
&lt;p&gt;But, what if we were to create a dictionary that related the letters N, E, S, W of the cardinal points with&amp;nbsp;numbers?&lt;/p&gt;
&lt;p&gt;I bet you already know the answer! But, there is another way, also very useful to generate dictionaries, and that can be very important for generating these dictionaries at&amp;nbsp;runtime.&lt;/p&gt;
&lt;p&gt;Using &lt;code&gt;dict()&lt;/code&gt; we can turn tuple lists into dictionaries. Technically it should be a sequence of sequences, but we&amp;rsquo;ll use a list of tuples to illustrate&amp;nbsp;that.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you don&amp;rsquo;t remember what a tuple is, check out our &lt;a href="http://programeempython.com.br/python-101-parte-7-en.html"&gt;Introduction to Data Structures&amp;nbsp;post&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here&amp;rsquo;s how &lt;code&gt;dict()&lt;/code&gt; works:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;cardinal&lt;/span&gt; &lt;span class="n"&gt;points&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="s1"&gt;'N'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'E'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'S'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'W'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Do you remember the &lt;a href="http://programeempython.com.br/python-101-parte-9-en.html"&gt;List Comprehension&lt;/a&gt; we saw in the last&amp;nbsp;post?&lt;/p&gt;
&lt;p&gt;Well, how about using it to build a dictionary that lists the integers from zero to ten and their respective&amp;nbsp;squares?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;squares&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;It&amp;rsquo;s very simple to create a dictionary, isn&amp;rsquo;t&amp;nbsp;it?&lt;/p&gt;
&lt;p&gt;But&amp;hellip; just creating the dictionaries is useless,&amp;nbsp;right?&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s see how to access a value from its key. let&amp;rsquo;s use the days of the week dictionary. Try the commands in the Python&amp;nbsp;Shell!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weekdays['tue']
two
&amp;gt;&amp;gt;&amp;gt; weekdays['sat']
6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Easy, isn&amp;rsquo;t&amp;nbsp;it?&lt;/p&gt;
&lt;p&gt;Shall we insert some values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;into this&amp;nbsp;dictionary?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weekdays
{'wed': 3, 'sun': 0, 'sat': 6, 'fri': 5, 'mon': 1, 'thu': 4, 'tue': 2}
&amp;gt;&amp;gt;&amp;gt; weekdays['Sun'] = 0
&amp;gt;&amp;gt;&amp;gt; weekdays['Mon'] = 1
&amp;gt;&amp;gt;&amp;gt; weekdays['Tue'] = 2
&amp;gt;&amp;gt;&amp;gt; weekdays['Wed'] = 3
&amp;gt;&amp;gt;&amp;gt; weekdays['Thu'] = 4
&amp;gt;&amp;gt;&amp;gt; weekdays['Fri'] = 5
&amp;gt;&amp;gt;&amp;gt; weekdays['Sat'] = 6
&amp;gt;&amp;gt;&amp;gt; weekdays
{'wed': 3, 'sun': 0, 'sat': 6, 'Sun': 0, 'mon': 1, 'fri': 5, 'Mon': 1,
'thu': 4, 'Wed': 3, 'Sat': 6, 'Thu': 4, 'tue': 2, 'Fri': 5, 'Tue': 2}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In a dictionary, the order in which the elements appear is not so important, as the values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;are accessed mainly through their respective keys, not their positions. In addition, dictionaries do not keep the order of elements, so the element that appears first in one execution may not be the first in another, even if the insertion was done in the same&amp;nbsp;way.&lt;/p&gt;
&lt;p&gt;If you need to check if a key is already in the dictionary, just do the&amp;nbsp;following&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 'mon' in weekdays
true
&amp;gt;&amp;gt;&amp;gt; 'bla' in weekdays
false
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Well, let&amp;rsquo;s say now that I no longer want the dictionary to have the capitalized version for&amp;nbsp;Sunday.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; del(weekdays['Sun])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is also possible to know which keys have already been&amp;nbsp;inserted:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; weekdays.keys()
['Sat', 'Mon', 'Fri', 'Wed', 'Thu', 'Tue', 'Wed', 'Sun', 'Sat', 'Fri',
'Mon', 'Thu', 'Tue']
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And what values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;are in the dictionary:
    &amp;gt;&amp;gt;&amp;gt; weekdays.values()
    [6, 1, 5, 3, 4, 2, 3, 0, 6, 5, 1, 4,&amp;nbsp;2]&lt;/p&gt;
&lt;p&gt;One important thing to note is that keys and dictionary elements can be of virtually any type, with the exception of keys which have a constraint. Objects have to be&amp;nbsp;immutable.&lt;/p&gt;
&lt;p&gt;This means that the list &lt;code&gt;[1, 2, 3]&lt;/code&gt; cannot be a dictionary key as we can change values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;in the list in the middle of the execution. The tuple &lt;code&gt;(1, 2, 3)&lt;/code&gt; that is immutable can be a dictionary key without any&amp;nbsp;problems.&lt;/p&gt;
&lt;p&gt;By now, you are familiar with Python Dictionaries, this data structure that has so many important&amp;nbsp;applications.&lt;/p&gt;
&lt;p&gt;Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Parte 9 - Estruturas de Dados - List Comprehention</title><link href="http://programeempython.com.br/python-101-parte-9.html" rel="alternate"></link><published>2022-08-22T23:06:00+02:00</published><updated>2022-08-22T23:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-22:/python-101-parte-9.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Como prometido, hoje vamos continuar o post falando sobre listas em Python, pois este &amp;eacute; uma assunto bastante&amp;nbsp;extenso.&lt;/p&gt;
&lt;p&gt;O assunto de hoje &amp;eacute; &lt;strong&gt;List Comprehension&lt;/strong&gt;, ou em portugu&amp;ecirc;s, abrang&amp;ecirc;ncia de listas. Como o termo em portugu&amp;ecirc;s n&amp;atilde;o retrata bem o que este recurso faz, vamos usar o termo …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Como prometido, hoje vamos continuar o post falando sobre listas em Python, pois este &amp;eacute; uma assunto bastante&amp;nbsp;extenso.&lt;/p&gt;
&lt;p&gt;O assunto de hoje &amp;eacute; &lt;strong&gt;List Comprehension&lt;/strong&gt;, ou em portugu&amp;ecirc;s, abrang&amp;ecirc;ncia de listas. Como o termo em portugu&amp;ecirc;s n&amp;atilde;o retrata bem o que este recurso faz, vamos usar o termo em ingl&amp;ecirc;s&amp;nbsp;mesmo.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;List Comprehension&lt;/strong&gt; &amp;eacute; um recurso do Python que permite a cria&amp;ccedil;&amp;atilde;o de listas de forma simples, usando simplesmente uma express&amp;atilde;o seguida de um &lt;code&gt;for&lt;/code&gt; que pode conter outros &lt;code&gt;for&lt;/code&gt; e/ou &lt;code&gt;if&lt;/code&gt; dentro&amp;nbsp;dele.&lt;/p&gt;
&lt;p&gt;Tudo ficar&amp;aacute; mais claro ao partirmos para os&amp;nbsp;exemplos.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, vamos colocar a m&amp;atilde;o na massa! Abra o shell do&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;Lembre-se que o que deve ser digitado estar&amp;aacute; precedido de &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; ou &lt;code&gt;...&lt;/code&gt;, assim como aparecer&amp;aacute; no shell do&amp;nbsp;python.&lt;/p&gt;
&lt;p&gt;Se por acaso voc&amp;ecirc; n&amp;atilde;o entendeu do que estou falando, &amp;eacute; aconselh&amp;aacute;vel que voc&amp;ecirc; leia antes os posts anteriores que te deixar&amp;atilde;o em dia com tudo que vimos at&amp;eacute;&amp;nbsp;agora.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7.html"&gt;Estruturas de Dados do Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-8.html"&gt;Estruturas de Dados do Python -&amp;nbsp;Listas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Procure entender exatamente o que acontece em cada exemplo. Vamos&amp;nbsp;l&amp;aacute;!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;1, 2, 4&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3 * x for x in l&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3, 6, 12&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2 * x for x in l if x &amp;gt; 3&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;12&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="err"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[x, 2*x&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2, 4&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;4, 8&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;(x, 2*x) for x in l&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;(1, 2), (2, 4), (4, 8)&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;1, 2, 3&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x * y for x in l1 for y in l2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 0, 0, 1, 2, 3, 2, 4, 6&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;l1[i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 2, 6&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As instru&amp;ccedil;&amp;otilde;es s&amp;atilde;o sempre dadas no mesmo&amp;nbsp;padr&amp;atilde;o:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;[&amp;lt;expressao&amp;gt; for &amp;lt;vari&amp;aacute;vel&amp;gt; in &amp;lt;lista&amp;gt; [if &amp;lt;condi&amp;ccedil;&amp;atilde;o&amp;gt;] [for...]]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="na"&gt;*** As estruturas entre [] s&amp;atilde;o opcionais. ***&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora chegamos ao ponto em que devemos responder ao desafio do &amp;uacute;ltimo post da s&amp;eacute;rie Python 101 para&amp;nbsp;prosseguir.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span class="dquo"&gt;&amp;ldquo;&lt;/span&gt;Quem imagina como fazer uma matriz em Python usando o que vimos&amp;nbsp;hoje?&amp;rdquo;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A resposta &amp;eacute;: &lt;strong&gt;Criar listas de&amp;nbsp;listas!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, se&amp;nbsp;fizermos:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; m = [[1, 2, 3],[2, 3, 4]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Teremos a matriz m com 2 linhas e 3 colunas, contendo na primeira linha os valores &lt;code&gt;1, 2, 3&lt;/code&gt; e na segunda os valores &lt;code&gt;2, 3, 4&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Assim, podemo usar &lt;code&gt;list comprehention&lt;/code&gt; tamb&amp;eacute;m para criarmos matrizes. Chamamos este recurso de Nested List Comprehention &lt;em&gt;(nested = aninhado)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Vejamos o seguinte&amp;nbsp;exemplo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; m = [
...         [1, 2, 3],
...         [4, 5, 6],
...         [7, 8, 9],
...     ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Aqui, criamos uma matriz 3x3 com os valores de 1 a 9.
Agora, veja uma forma de trocar as linhas com as colunas da matriz&amp;nbsp;m:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[linha[i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;linha&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[1, 4, 7&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2, 5, 8&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3, 6, 9&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Acho que por hoje, este recurso est&amp;aacute; bem ilustrado. N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 9 - Data Structures - List Comprehention</title><link href="http://programeempython.com.br/python-101-parte-9-en.html" rel="alternate"></link><published>2022-08-22T23:06:00+02:00</published><updated>2022-08-22T23:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-22:/python-101-parte-9-en.html</id><summary type="html">&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;As promised, today we are going to continue the post talking about lists in Python, as this is a very extensive&amp;nbsp;subject.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s topic is List&amp;nbsp;Comprehension.&lt;/p&gt;
&lt;p&gt;List Comprehension is a Python feature that allows the creation of lists in a simple way, simply using an expression followed …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;As promised, today we are going to continue the post talking about lists in Python, as this is a very extensive&amp;nbsp;subject.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s topic is List&amp;nbsp;Comprehension.&lt;/p&gt;
&lt;p&gt;List Comprehension is a Python feature that allows the creation of lists in a simple way, simply using an expression followed by a &lt;code&gt;for&lt;/code&gt; that can contain another &lt;code&gt;for&lt;/code&gt; and/or &lt;code&gt;if&lt;/code&gt; within&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Everything will become clearer as we move on to the&amp;nbsp;examples.&lt;/p&gt;
&lt;p&gt;So, let&amp;rsquo;s get our hands dirty! Open the Python&amp;nbsp;shell.&lt;/p&gt;
&lt;p&gt;Remember that what must be typed will be preceded by &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;...&lt;/code&gt;, as it will appear in the python&amp;nbsp;shell.&lt;/p&gt;
&lt;p&gt;If by any chance you don&amp;rsquo;t understand what I&amp;rsquo;m talking about, it&amp;rsquo;s advisable that you read the previous posts beforehand, which will keep you up to date with everything we&amp;rsquo;ve seen so&amp;nbsp;far.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Frameworks in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Frameworks in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repeat Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repeat Structures -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7-en.html"&gt;Python Data Structures -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-8-en.html"&gt;Python Data Structures -&amp;nbsp;Lists&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Try to understand exactly what happens in each example. Come&amp;nbsp;on!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;1, 2, 4&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3 * x for x in l&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3, 6, 12&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2 * x for x in l if x &amp;gt; 3&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;12&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[x, 2*x&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2, 4&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;4, 8&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;(x, 2*x) for x in l&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;(1, 2), (2, 4), (4, 8)&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;1, 2, 3&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x * y for x in l1 for y in l2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 0, 0, 1, 2, 3, 2, 4, 6&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;l1[i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 2, 6&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The instructions are always given in the same&amp;nbsp;pattern:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;[&amp;lt;expression&amp;gt; for &amp;lt;variable&amp;gt; in &amp;lt;list&amp;gt; [if &amp;lt;condition&amp;gt;] [for...]]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="na"&gt;*** Structures between [] are optional. ***&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we come to the point where we must answer last Python 101 post&amp;rsquo;s challenge in order to&amp;nbsp;proceed.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span class="dquo"&gt;&amp;ldquo;&lt;/span&gt;Who can imagine how to make an array in Python using what we saw&amp;nbsp;today?&amp;rdquo;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The answer is: &lt;strong&gt;Create lists of&amp;nbsp;lists!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So if we&amp;nbsp;do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; m = [[1, 2, 3],[2, 3, 4]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We will have the matrix m with 2 rows and 3 columns, containing in the first row the values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;&lt;code&gt;1, 2, 3&lt;/code&gt; and in the second the values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;&lt;code&gt;2, 3, 4&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So we can use &lt;code&gt;list comprehention&lt;/code&gt; to create matrices as well. We call this feature Nested List&amp;nbsp;Comprehention.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s look at the following&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; m = [
... [1, 2, 3],
... [4, 5, 6],
... [7, 8, 9],
... ]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, we create a 3x3 matrix with values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;from 1 to 9.
Now, here&amp;rsquo;s a way to exchange the rows with the columns of the matrix&amp;nbsp;m:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[line[i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;0, 1, 2&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;[1, 4, 7&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2, 5, 8&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;3, 6, 9&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I think for today, this feature is well illustrated. Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Tutorial de Pelican com Github Pages e CircleCI - 3</title><link href="http://programeempython.com.br/tutorial-pelican-3.html" rel="alternate"></link><published>2022-08-15T09:30:00+02:00</published><updated>2022-08-15T09:30:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-15:/tutorial-pelican-3.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hora de continuar nosso tutorial e colocarmos nosso blog Pelican no github&amp;nbsp;pages!&lt;/p&gt;
&lt;p&gt;Caso voc&amp;ecirc; ainda n&amp;atilde;o tenha visto os posts anteriores, veja aqui para podermos seguir do mesmo&amp;nbsp;ponto.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican.html"&gt;Tutorial Inicial de Pelican&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1.html"&gt;Tutorial b&amp;aacute;sico de &lt;span class="caps"&gt;GIT&lt;/span&gt; e&amp;nbsp;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-2.html"&gt;Tutorial de Github&amp;nbsp;Pages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Recapitulando rapidamente, no primeiro tutorial …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hora de continuar nosso tutorial e colocarmos nosso blog Pelican no github&amp;nbsp;pages!&lt;/p&gt;
&lt;p&gt;Caso voc&amp;ecirc; ainda n&amp;atilde;o tenha visto os posts anteriores, veja aqui para podermos seguir do mesmo&amp;nbsp;ponto.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican.html"&gt;Tutorial Inicial de Pelican&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1.html"&gt;Tutorial b&amp;aacute;sico de &lt;span class="caps"&gt;GIT&lt;/span&gt; e&amp;nbsp;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-2.html"&gt;Tutorial de Github&amp;nbsp;Pages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Recapitulando rapidamente, no primeiro tutorial n&amp;oacute;s criamos um site bem simples com Pelican e no terceiro n&amp;oacute;s criamos uma p&amp;aacute;gina bastante simples no github&amp;nbsp;pages.&lt;/p&gt;
&lt;p&gt;A estrutura atual do seu diret&amp;oacute;rio do github pages deve ser algo&amp;nbsp;como&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;usuario.github.io/
    index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Bom, n&amp;atilde;o vamos usar este arquivo&amp;nbsp;html.&lt;/p&gt;
&lt;p&gt;No terminal, vamos criar uma nova branch, que ser&amp;aacute; nossa branch principal para criarmos todos os textos do&amp;nbsp;blog. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git checkout -b pelican
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Este comando criar&amp;aacute; uma nova branch no seu reposit&amp;oacute;rio git local e vai automaticamente mudar a branch atual para &lt;code&gt;pelican&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Vamos apagar o arquivo&amp;nbsp;html.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;rm index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;E agora vamos criar nosso blog. Precisamos ter acesso aqui ao comando &lt;code&gt;pelican-quickstart&lt;/code&gt; que usamos no tutorial de pelican, ent&amp;atilde;o, num ambiente que contenha o pelican (pode ser o mesmo que usamos no tutorial de pelican), digite o&amp;nbsp;comando:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican-quickstart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Desta vez n&amp;atilde;o vamos ficar nos par&amp;acirc;metros padr&amp;atilde;o. Adapte as escolhas que eu mostrar a seguir ao seu&amp;nbsp;projeto.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Simplesmente aperte `Enter` para usar a op&amp;ccedil;&amp;atilde;o padr&amp;atilde;o.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# Caso tenha um nome para o blog, ele vai aqui, sen&amp;atilde;o, usuario.github.io pode ser uma boa&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Who&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Aqui, ser&amp;aacute; seu nome&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;language&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# `pt` n&amp;atilde;o &amp;eacute; uma op&amp;ccedil;&amp;atilde;o v&amp;aacute;lida, ent&amp;atilde;o use `pt_BR`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;specify&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prefix&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;://&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Aqui responda `y` e depois a url do seu blog (https://usuario.github.io por exemplo&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;enable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pagination&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Sempre acho uma boa ideia ter pagina&amp;ccedil;&amp;atilde;o, ent&amp;atilde;o, `Y`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;How&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;many&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;per&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;page&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Aqui tamb&amp;eacute;m recomendo o padro, `Enter`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;zone&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="n"&gt;America&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Sao_Paulo&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# Use aqui o que fizer mais sentido pra voc&amp;ecirc;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Makefile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;automate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;publishing&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Esta &amp;eacute; a parte mais importante. A resposta aqui &amp;eacute; SIM! `Y`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;FTP&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# N&amp;oacute;s n&amp;atilde;o queremos, ent&amp;atilde;o `n`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SSH&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# Mesmo aqui, `n`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Dropbox&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# Aqui, `n`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;S3&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# Aqui, `n'&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Rackspace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Cloud&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Files&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;#E aqui, `n`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;upload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;website&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;GitHub&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Pages&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="c1"&gt;# N&amp;oacute;s queremos usar github pages ent&amp;atilde;o a resposta aqui &amp;eacute; `y`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;personal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;page&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;io&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nv"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="c1"&gt;# E sim, &amp;eacute; a p&amp;aacute;gina pessoal, ent&amp;atilde;o, `y`&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Vamos precisar da lib de Python que interage com github pages ent&amp;atilde;o vamos&amp;nbsp;instal&amp;aacute;-la:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install ghp-import
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Para o caso de precisarmos editar este reposit&amp;oacute;rio em outro local, outro ambiente, vamos criar um arquivo &lt;code&gt;requirements.txt&lt;/code&gt; que vai&amp;nbsp;conter&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;ghp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;import&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto nos permite instalar facilmente as depend&amp;ecirc;ncias no futuro com o&amp;nbsp;comando&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Mais uma vez voc&amp;ecirc; deve ter uma estrutura de arquivos dentro do seu reposit&amp;oacute;rio parecida com&amp;nbsp;isto:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content/
pelicanconf.py
publishconf.py
requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Vamos dar uma olhada no arquivo&amp;nbsp;pelicanconf.py&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;AUTHOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Author Name'&lt;/span&gt;
&lt;span class="n"&gt;SITENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'My Blog'&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="n"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'content'&lt;/span&gt;

&lt;span class="n"&gt;TIMEZONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'America/Sao_Paulo'&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_LANG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'pt'&lt;/span&gt;

&lt;span class="c1"&gt;# Feed generation is usually not desired when developing&lt;/span&gt;
&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;TRANSLATION_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;AUTHOR_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;AUTHOR_FEED_RSS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="c1"&gt;# Blogroll&lt;/span&gt;
&lt;span class="n"&gt;LINKS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'Pelican'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://getpelican.com/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Python.org'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://www.python.org/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Jinja2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://palletsprojects.com/p/jinja/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'You can modify those links in your config file'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),)&lt;/span&gt;

&lt;span class="c1"&gt;# Social widget&lt;/span&gt;
&lt;span class="n"&gt;SOCIAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'You can add links in your config file'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Another social link'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),)&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_PAGINATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Uncomment following line if you want document-relative URLs when developing&lt;/span&gt;
&lt;span class="c1"&gt;#RELATIVE_URLS = True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Podemos remover os links e acrescentar links mais relevantes. Tamb&amp;eacute;m podemos acrescentar links para redes&amp;nbsp;sociais.&lt;/p&gt;
&lt;p&gt;Vamos acrescentar uma &lt;span class="caps"&gt;URL&lt;/span&gt; para quando estivermos rodando o blog em modo de desenvolvimento para vermos como est&amp;aacute; o post, por&amp;nbsp;exemplo.&lt;/p&gt;
&lt;p&gt;Em &lt;code&gt;SITEURL&lt;/code&gt; insira &lt;code&gt;'http://localhost:8000'&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Agora vamos criar um post em content e podemos chamar por exemplo de &lt;code&gt;primeiro-post.md&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Sua estrutura de arquivos&amp;nbsp;ficar&amp;aacute;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content/
    primeiro-post.md
pelicanconf.py
publishconf.py
requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Em &lt;code&gt;primeiro-post.md&lt;/code&gt; escreva:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nl"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Primeiro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;08&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Geral&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Geral&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;primeiro&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Ol&amp;aacute;&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;Este&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;&amp;eacute;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;meu&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;primeiro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;Isto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;&amp;eacute;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;um&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;&amp;Eacute;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;muito&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;__f&amp;aacute;cil__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;criar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;_Pelican_&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Aqui temos a estrutura de um post bem simples, com metadados b&amp;aacute;sicos e um exemplo de texto que exemplifica algumas marca&amp;ccedil;&amp;otilde;es do&amp;nbsp;Markdown.&lt;/p&gt;
&lt;p&gt;Vamos test&amp;aacute;-lo no servidor de&amp;nbsp;testes.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AutoReload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Monitoring&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`content`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`theme`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`settings`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Serving&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;at&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;://&lt;/span&gt;&lt;span class="mf"&gt;127.0.0.1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Tap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CTRL&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;04&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;Watched&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;does&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;exist&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;io&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;


&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Modified&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="n"&gt;tings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generating&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Processed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;drafts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.06&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Acesse &lt;a href="http://localhost:8000"&gt;o servidor local&lt;/a&gt; e voc&amp;ecirc; deve ver algo&amp;nbsp;assim:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Server local" src="/images/pelican-blog-first.png"/&gt;&lt;/p&gt;
&lt;p&gt;Para continuarmos, voc&amp;ecirc; precisa ter instalado o &lt;code&gt;make&lt;/code&gt;. Como no Windows a instala&amp;ccedil;&amp;atilde;o do make &amp;eacute; mais chatinha, segue um &lt;a href="https://coffops.com/usando-comando-make-projetos-windows/"&gt;tutorial de make no Windows&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Podemos usar o make para v&amp;aacute;rias&amp;nbsp;tarefas.&lt;/p&gt;
&lt;p&gt;Para executar um servidor de desenvolvimento, podemos&amp;nbsp;usar&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make devserver
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Podemos simplesmente gerar os arquivos para deploy&amp;nbsp;com&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make publish
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;E para enviarmos para o github, vamos&amp;nbsp;usar:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make github
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Por&amp;eacute;m, antes de enviarmos nosso projeto para o github pages vamos conferir a configura&amp;ccedil;&amp;atilde;o do blog para publica&amp;ccedil;&amp;atilde;o. Abra o arquivo &lt;code&gt;publishconf.py&lt;/code&gt;. Ele deve ter aproximadamente este&amp;nbsp;conte&amp;uacute;do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# This file is only used if you use `make publish` or&lt;/span&gt;
&lt;span class="c1"&gt;# explicitly specify it as your config file.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;curdir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pelicanconf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# If your site is available via HTTPS, make sure SITEURL begins with https://&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://jcempython.github.io'&lt;/span&gt;
&lt;span class="n"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/all.atom.xml'&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/&lt;/span&gt;&lt;span class="si"&gt;{slug}&lt;/span&gt;&lt;span class="s1"&gt;.atom.xml'&lt;/span&gt;

&lt;span class="n"&gt;DELETE_OUTPUT_DIRECTORY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;

&lt;span class="c1"&gt;# Following items are often useful when publishing&lt;/span&gt;

&lt;span class="c1"&gt;#DISQUS_SITENAME = ""&lt;/span&gt;
&lt;span class="c1"&gt;#GOOGLE_ANALYTICS = ""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Em alguns instantes voc&amp;ecirc; poder&amp;aacute; acessar seu site &lt;code&gt;usuario.github.io&lt;/code&gt; e ver seu blog no&amp;nbsp;ar!&lt;/p&gt;
&lt;p&gt;Quando escrever novos posts, simplesmente execute &lt;code&gt;make publish&lt;/code&gt; e &lt;code&gt;make github&lt;/code&gt; e em alguns instantes seu post estar&amp;aacute; no&amp;nbsp;ar!&lt;/p&gt;
&lt;p&gt;Por hora &amp;eacute; isto! Tenho certeza que voc&amp;ecirc; j&amp;aacute; vai se divertir muito com seu blog e j&amp;aacute; vai poder come&amp;ccedil;ar a postar tudo que&amp;nbsp;quiser!&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o se esque&amp;ccedil;a, quando terminar de fazer altera&amp;ccedil;&amp;otilde;es no seu blog, de fazer um commit das altera&amp;ccedil;&amp;otilde;es para a branch pelican&amp;nbsp;tamb&amp;eacute;m.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;git&lt;/span&gt; &lt;span class="nv"&gt;add&lt;/span&gt; .
&lt;span class="nv"&gt;git&lt;/span&gt; &lt;span class="nv"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;m&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;uma mensagem do que foi feito&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;git&lt;/span&gt; &lt;span class="nv"&gt;push&lt;/span&gt; &lt;span class="nv"&gt;origin&lt;/span&gt; &lt;span class="nv"&gt;pelican&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim voc&amp;ecirc; n&amp;atilde;o corre o risco de perder suas altera&amp;ccedil;&amp;otilde;es e tem sempre controle sobre as vers&amp;otilde;es dos textos que vau&amp;nbsp;publicar!&lt;/p&gt;
&lt;p&gt;No pr&amp;oacute;ximo post vamos dar um tapa neste blog para termos mais fun&amp;ccedil;&amp;otilde;es, como coment&amp;aacute;rios, por&amp;nbsp;exemplo.&lt;/p&gt;
&lt;p&gt;Espero que tenham gostado e n&amp;atilde;o esque&amp;ccedil;am de deixar suas opini&amp;otilde;es e d&amp;uacute;vidas nos&amp;nbsp;coment&amp;aacute;rios!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Pelican Tutorial with Github Pages and CircleCI - 3</title><link href="http://programeempython.com.br/tutorial-pelican-3-en.html" rel="alternate"></link><published>2022-08-15T09:30:00+02:00</published><updated>2022-08-15T09:30:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-15:/tutorial-pelican-3-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s time to continue our tutorial and put our Pelican blog on github&amp;nbsp;pages!&lt;/p&gt;
&lt;p&gt;Just in case you haven&amp;rsquo;t seen the previous posts, check here so we can follow from the same&amp;nbsp;page.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-en.html"&gt;Starter Pelican Tutorial&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1-en.html"&gt;Basic &lt;span class="caps"&gt;GIT&lt;/span&gt; and GitHub&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-2-en.html"&gt;Github Pages&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To recap quickly …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s time to continue our tutorial and put our Pelican blog on github&amp;nbsp;pages!&lt;/p&gt;
&lt;p&gt;Just in case you haven&amp;rsquo;t seen the previous posts, check here so we can follow from the same&amp;nbsp;page.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-en.html"&gt;Starter Pelican Tutorial&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1-en.html"&gt;Basic &lt;span class="caps"&gt;GIT&lt;/span&gt; and GitHub&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-2-en.html"&gt;Github Pages&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To recap quickly, in the first tutorial we created a very simple site with Pelican and in the third we created a very simple page on github&amp;nbsp;pages.&lt;/p&gt;
&lt;p&gt;The current structure of your github pages directory should look something&amp;nbsp;like&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;username.github.io/
    index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Well, let&amp;rsquo;s not use this html&amp;nbsp;file.&lt;/p&gt;
&lt;p&gt;In the terminal, let&amp;rsquo;s create a new branch, which will be our main branch to create all the blog&amp;nbsp;texts.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git checkout -b pelican
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This command will create a new branch in your local git repository and will automatically change the current branch to &lt;code&gt;pelican&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s delete the html&amp;nbsp;file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;rm index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And now let&amp;rsquo;s create our blog. We need access here to the &lt;code&gt;pelican-quickstart&lt;/code&gt; command that we used in the pelican tutorial, so, in an environment that contains the pelican (may be the same one we used in the pelican tutorial), type the&amp;nbsp;command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican-quickstart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This time we are not going to stick to the default parameters. Adapt the choices I show below to your&amp;nbsp;project.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt; &lt;span class="n"&gt;Where&lt;/span&gt; &lt;span class="nb"&gt;do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="nb"&gt;new&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt;? [.]
&lt;span class="c1"&gt;# Simply press `Enter` to use the default option.&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="nb"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt;?
&lt;span class="c1"&gt;# If you have a name for the blog, it goes here, otherwise, username.github.io might be a good idea&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Who&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;author&lt;/span&gt; &lt;span class="nb"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt;?
&lt;span class="c1"&gt;# Here will be your name&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt; &lt;span class="nb"&gt;of&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt;? [&lt;span class="n"&gt;en&lt;/span&gt;]
&lt;span class="c1"&gt;# `pt` is not a valid option, so use `pt_BR`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;specify&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;URL&lt;/span&gt; &lt;span class="nb"&gt;prefix&lt;/span&gt;? &lt;span class="nb"&gt;e&lt;/span&gt;.&lt;span class="n"&gt;g&lt;/span&gt;., &lt;span class="n"&gt;https:&lt;/span&gt;//&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt; (&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# Here answer `y` and then the url of your blog (https://username.github.io for example)&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;enable&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt; &lt;span class="n"&gt;pagination&lt;/span&gt;? (&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# I always think it's a good idea to have pagination, so `Y`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;How&lt;/span&gt; &lt;span class="n"&gt;many&lt;/span&gt; &lt;span class="n"&gt;articles&lt;/span&gt; &lt;span class="n"&gt;per&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="nb"&gt;do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt;? [&lt;span class="mi"&gt;10&lt;/span&gt;]
&lt;span class="c1"&gt;# Here I also recommend the default, `Enter`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="n"&gt;zone&lt;/span&gt;? [&lt;span class="n"&gt;America&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;New_York&lt;/span&gt;]
&lt;span class="c1"&gt;# Use here what makes the most sense to you&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;generate&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt;.&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Makefile&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;automate&lt;/span&gt; &lt;span class="n"&gt;generation&lt;/span&gt; &lt;span class="o"&gt;and&lt;/span&gt; &lt;span class="n"&gt;publishing&lt;/span&gt;? (&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# This is the most important part. The answer here is YES! `Y`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;FTP&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# We don't want to, so `n`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;SSH&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# Even here, `n`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Dropbox&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# Here, `n`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;S3&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# Here, `n'&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Rackspace&lt;/span&gt; &lt;span class="n"&gt;Cloud&lt;/span&gt; &lt;span class="n"&gt;Files&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;#And here, `n`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="nb"&gt;to&lt;/span&gt; &lt;span class="n"&gt;upload&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;website&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;GitHub&lt;/span&gt; &lt;span class="n"&gt;Pages&lt;/span&gt;? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# We want to use github pages so the answer here is `y`&lt;/span&gt;
&amp;gt; &lt;span class="n"&gt;Is&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;personal&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; (&lt;span class="n"&gt;username&lt;/span&gt;.&lt;span class="n"&gt;github&lt;/span&gt;.&lt;span class="n"&gt;io&lt;/span&gt;)? (&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;)
&lt;span class="c1"&gt;# And yes, it's the personal page, so `y`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We&amp;rsquo;re going to need the Python lib that interacts with github pages so let&amp;rsquo;s install&amp;nbsp;it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install ghp-import
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In case we need to edit this repository in another location, another environment, let&amp;rsquo;s create a &lt;code&gt;requirements.txt&lt;/code&gt; file that will&amp;nbsp;contain&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;ghp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;import&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This allows us to easily install dependencies in the future with the&amp;nbsp;command&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once again you should have a file structure within your repository that looks like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content/
pelicanconf.py
publishconf.py
requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let&amp;rsquo;s take a look at the pelicanconf.py&amp;nbsp;file&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;AUTHOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Author Name'&lt;/span&gt;
&lt;span class="n"&gt;SITENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'My Blog'&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="n"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'content'&lt;/span&gt;

&lt;span class="n"&gt;TIMEZONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'America/New_York'&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_LANG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'en'&lt;/span&gt;

&lt;span class="c1"&gt;# Feed generation is usually not desired when developing&lt;/span&gt;
&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;TRANSLATION_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;AUTHOR_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;AUTHOR_FEED_RSS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="c1"&gt;# blogroll&lt;/span&gt;
&lt;span class="n"&gt;LINKS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'Pelican'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://getpelican.com/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Python.org'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://www.python.org/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Jinja2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'https://palletsprojects.com/p/jinja/'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'You can modify those links in your config file'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),)&lt;/span&gt;

&lt;span class="c1"&gt;# Social widget&lt;/span&gt;
&lt;span class="n"&gt;SOCIAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'You can add links in your config file'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Another social link'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#'&lt;/span&gt;&lt;span class="p"&gt;),)&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_PAGINATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# Uncomment following line if you want document-relative URLs when developing&lt;/span&gt;
&lt;span class="c1"&gt;#RELATIVE_URLS = True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;We may remove links and add more relevant links. We can also add links to social networks.
Let&amp;rsquo;s add a &lt;span class="caps"&gt;URL&lt;/span&gt; for when we are running the blog in development mode to see how the post is doing, for&amp;nbsp;example.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;SITEURL&lt;/code&gt; enter &lt;code&gt;'http://localhost:8000'&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s create a post in content and we can call it for example &lt;code&gt;first-post.md&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Your file structure will&amp;nbsp;be&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content/
    first-post.md
pelicanconf.py
publishconf.py
requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In &lt;code&gt;first-post.md&lt;/code&gt; write:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nl"&gt;Title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;First&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;08&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;General&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Tags&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;General&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="nl"&gt;Slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;first&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Hello&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;first&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;It&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;very&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;__easy__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;_Pelican_&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we have the structure of a very simple post, with basic metadata and an example text that exemplifies some Markdown&amp;nbsp;markup.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s test it on the test&amp;nbsp;server.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AutoReload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Monitoring&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`content`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`theme`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`settings`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Serving&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;at&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;://&lt;/span&gt;&lt;span class="mf"&gt;127.0.0.1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Tap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CTRL&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;04&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;41&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Watched&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;does&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;exist&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;io&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;


&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Modified&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="n"&gt;tings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generating&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Processed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;drafts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.06&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Go to &lt;a href="http://localhost:8000"&gt;the local server&lt;/a&gt; and you should see something like&amp;nbsp;this:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Local Server" src="/images/pelican-blog-first.png"/&gt;&lt;/p&gt;
&lt;p&gt;To continue, you need to have &lt;code&gt;make&lt;/code&gt; installed. As the installation of make is more annoying on Windows, follow a &lt;a href="https://www.technewstoday.com/install-and-use-make-in-windows/"&gt;make tutorial on Windows&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We can use make for many&amp;nbsp;tasks.&lt;/p&gt;
&lt;p&gt;To run a development server we can&amp;nbsp;use&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make devserver
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We can simply generate the files for deploy&amp;nbsp;with&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make publish
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And to upload to github, let&amp;rsquo;s&amp;nbsp;use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;make github
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;However, before we upload our project to github pages, let&amp;rsquo;s check the configuration of the blog for publishing. Open the &lt;code&gt;publishconf.py&lt;/code&gt; file. It should have approximately this&amp;nbsp;content:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# This file is only used if you use `make publish` or&lt;/span&gt;
&lt;span class="c1"&gt;# explicitly specify it as your config file.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;them&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;curdir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pelicanconf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# If your site is available via HTTPS, make sure SITEURL begins with https://&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://jcempython.github.io'&lt;/span&gt;
&lt;span class="n"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/all.atom.xml'&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/&lt;/span&gt;&lt;span class="si"&gt;{slug}&lt;/span&gt;&lt;span class="s1"&gt;.atom.xml'&lt;/span&gt;

&lt;span class="n"&gt;DELETE_OUTPUT_DIRECTORY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;

&lt;span class="c1"&gt;# Following items are often useful when publishing&lt;/span&gt;

&lt;span class="c1"&gt;#DISQUS_SITENAME = ""&lt;/span&gt;
&lt;span class="c1"&gt;#GOOGLE_ANALYTICS = ""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;In a few moments you will be able to access your site &lt;code&gt;username.github.io&lt;/code&gt; and see your blog&amp;nbsp;live!&lt;/p&gt;
&lt;p&gt;When writing new posts, simply run &lt;code&gt;make publish&lt;/code&gt; and &lt;code&gt;make github&lt;/code&gt; and in a few moments your post will be&amp;nbsp;live!&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s it for an hour! I&amp;rsquo;m sure you&amp;rsquo;ll have a lot of fun with your blog and you&amp;rsquo;ll be able to start posting whatever you&amp;nbsp;want!&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t forget, when you&amp;rsquo;re done making changes to your blog, to commit the changes to the pelican branch as&amp;nbsp;well.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git add .
git commit -m "a message of what was done"
git push origin pelican
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So you don&amp;rsquo;t run the risk of losing your changes and you always have control over the versions of the texts that I&amp;rsquo;m going to&amp;nbsp;publish!&lt;/p&gt;
&lt;p&gt;In the next post we&amp;rsquo;ll slap this blog to have more functions, like comments, for&amp;nbsp;example.&lt;/p&gt;
&lt;p&gt;Hope you liked it and don&amp;rsquo;t forget to leave your opinions and questions in the&amp;nbsp;comments!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Python 101 - Parte 8 - Estruturas de Dados - Listas</title><link href="http://programeempython.com.br/python-101-parte-8.html" rel="alternate"></link><published>2022-08-13T02:06:00+02:00</published><updated>2022-08-13T02:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-13:/python-101-parte-8.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Vou falar hoje sobre Listas em&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7.html"&gt;Estruturas de Dados do Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Listas …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Vou falar hoje sobre Listas em&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7.html"&gt;Estruturas de Dados do Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Listas s&amp;atilde;o conjuntos ordenados de dados. Em python, estes conjuntos podem conter v&amp;aacute;rios tipos de dados misturados, visto que tudo em Python &amp;eacute;&amp;nbsp;objeto.&lt;/p&gt;
&lt;p&gt;Assim, al&amp;eacute;m de tipos de dados b&amp;aacute;sicos como inteiros, n&amp;uacute;meros reais e texto, as listas podem conter qualquer outro objeto da&amp;nbsp;linguagem.&lt;/p&gt;
&lt;p&gt;Vejamos como as listas s&amp;atilde;o criadas em&amp;nbsp;python:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;
&lt;span class="normal"&gt;7&lt;/span&gt;
&lt;span class="normal"&gt;8&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# Criando uma lista vazia&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;#Criando uma lista j&amp;aacute; com valores&lt;/span&gt;
&lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;#Criando uma lista de letras a partir de uma string&lt;/span&gt;
&lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"abracadabra"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;No primeiro comando, criamos uma lista vazia, que poder&amp;aacute; ser preenchida futuramente. Em seguida, criamos uma lista, j&amp;aacute; atribuindo valores no momento da&amp;nbsp;cria&amp;ccedil;&amp;atilde;o.&lt;/p&gt;
&lt;p&gt;Perceba que ao criar a lista s&amp;atilde;o passados valores inteiros, letras e a lista que foi criada vazia anteriormente. Assim, demonstramos que uma lista pode receber qualquer tipo de objeto, e que pode ter objetos de tipos diferentes ao mesmo&amp;nbsp;tempo!&lt;/p&gt;
&lt;p&gt;Na lista tr&amp;ecirc;s, utilizamos &lt;code&gt;list()&lt;/code&gt; para criar um objeto &lt;code&gt;list&lt;/code&gt; a partir de um &lt;code&gt;string&lt;/code&gt;. Isto &amp;eacute; poss&amp;iacute;vel porque tanto listas quanto strings s&amp;atilde;o&amp;nbsp;sequ&amp;ecirc;ncias.&lt;/p&gt;
&lt;p&gt;Mas, as listas em Python n&amp;atilde;o s&amp;atilde;o est&amp;aacute;ticas. Podemos inserir e retirar valores conforme bem quisermos a qualquer hora durante a execu&amp;ccedil;&amp;atilde;o do programa.&amp;nbsp;Vejamos:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;
&lt;span class="normal"&gt;32&lt;/span&gt;
&lt;span class="normal"&gt;33&lt;/span&gt;
&lt;span class="normal"&gt;34&lt;/span&gt;
&lt;span class="normal"&gt;35&lt;/span&gt;
&lt;span class="normal"&gt;36&lt;/span&gt;
&lt;span class="normal"&gt;37&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# vamos acrescentar valores &amp;agrave; lista l criada anteriormente&lt;/span&gt;
&lt;span class="c1"&gt;# append(o) insere um objeto o no final da lista&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# insert(i, o), insere o objeto o na posi&amp;ccedil;&amp;atilde;o i (a primeira posi&amp;ccedil;&amp;atilde;o &amp;eacute; zero)&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [5, 1, 2, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# remove(o) remove a primeira ocorr&amp;ecirc;ncia do objeto o&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [5, 1, 2, 3, 5]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3, 5]&lt;/span&gt;

&lt;span class="c1"&gt;# pop(i) remove e retorna o objeto da posi&amp;ccedil;&amp;atilde;o i&lt;/span&gt;
&lt;span class="c1"&gt;# pop() remove e retorna o &amp;uacute;ltimo elemento da lista&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3, 6, 5]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3, 5] e retornar&amp;aacute; 6&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3] e retornar&amp;aacute; 5&lt;/span&gt;

&lt;span class="c1"&gt;#index(o) retorna o &amp;iacute;ndice do objeto o&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# retorna 2&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3, 3]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# continua retornando 2 pois &amp;eacute; a primeira ocorr&amp;ecirc;ncia do 3&lt;/span&gt;

&lt;span class="c1"&gt;# count(o) conta quantas vezes o objeto o aparece na lista&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# retorna 1&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# retorna 2&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3] e retorna 3&lt;/span&gt;

&lt;span class="c1"&gt;# extend(L) estende a lista com a lista L&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [1, 2, 3, 0, -1, -2]&lt;/span&gt;

&lt;span class="c1"&gt;# sort() organiza os itens da lista nela mesma&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [-2, -1, 0, 1, 2, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# reverse() inverte os elementos da lista nela mesma&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# a lista ficar&amp;aacute; assim [3, 2, 1, 0, -1, -2]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Agora &amp;eacute; hora de&amp;nbsp;treinar!&lt;/p&gt;
&lt;p&gt;Abram o terminal, e comecem a brincar com as listas! Vejam como funcionam os&amp;nbsp;comandos!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Uma dica! O comando &lt;code&gt;help&lt;/code&gt; mostra informa&amp;ccedil;&amp;otilde;es sobre um comando! Experimente, ap&amp;oacute;s
criar uma lista l, o&amp;nbsp;comando:&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;help(l.sort)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No pr&amp;oacute;ximo post vamos falar de uma opera&amp;ccedil;&amp;atilde;o que tem tudo a ver com listas: List&amp;nbsp;Comprehension.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Um&amp;nbsp;desafio!&lt;/p&gt;
&lt;p&gt;Quem imagina como fazer uma matriz em Python usando o que vimos&amp;nbsp;hoje?&lt;/p&gt;
&lt;p&gt;Deixe sua resposta nos&amp;nbsp;coment&amp;aacute;rios!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Parte 8 - Data Structures - Lists</title><link href="http://programeempython.com.br/python-101-parte-8-en.html" rel="alternate"></link><published>2022-08-13T02:06:00+02:00</published><updated>2022-08-13T02:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-13:/python-101-parte-8-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today I&amp;rsquo;m going to talk about Lists in&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repetition Structures -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7-en.html"&gt;Data Structures in Python -&amp;nbsp;1 …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today I&amp;rsquo;m going to talk about Lists in&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repetition Structures -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-7-en.html"&gt;Data Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lists are ordered sets of data. In python, these sets can contain many mixed data types, since everything in Python is an&amp;nbsp;object.&lt;/p&gt;
&lt;p&gt;So, in addition to basic data types like integers, real numbers, and text, lists can contain any other language&amp;nbsp;object.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s see how lists are created in&amp;nbsp;python:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;
&lt;span class="normal"&gt;7&lt;/span&gt;
&lt;span class="normal"&gt;8&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# Creating an empty list&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;#Creating a list with values&lt;/span&gt;
&lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Creating a list of letters from a string&lt;/span&gt;
&lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"abracadabra"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;In the first command, we create an empty list, which can be filled in the future. Next, we create a list, already assigning values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;at the time of&amp;nbsp;creation.&lt;/p&gt;
&lt;p&gt;Note that when creating the list, integer values, letters and the list that was created empty previously are passed. Thus, we demonstrate that a list can receive any type of object, and that it can have objects of different types at the same&amp;nbsp;time!&lt;/p&gt;
&lt;p&gt;In the third list creation, we use &lt;code&gt;list()&lt;/code&gt; to create a &lt;code&gt;list&lt;/code&gt; object from a &lt;code&gt;string&lt;/code&gt;. This is possible because both lists and strings are&amp;nbsp;sequences.&lt;/p&gt;
&lt;p&gt;But, Python lists are not static. We can insert and remove values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;as we please at any time during program execution. Let&amp;rsquo;s&amp;nbsp;see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;
&lt;span class="normal"&gt;32&lt;/span&gt;
&lt;span class="normal"&gt;33&lt;/span&gt;
&lt;span class="normal"&gt;34&lt;/span&gt;
&lt;span class="normal"&gt;35&lt;/span&gt;
&lt;span class="normal"&gt;36&lt;/span&gt;
&lt;span class="normal"&gt;37&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# let's add values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;to the list l created earlier&lt;/span&gt;
&lt;span class="c1"&gt;# append(o) inserts an object o at the end of the list&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# insert(i, o), insert object o at position i (first position is zero)&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [5, 1, 2, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# remove(o) removes the first occurrence of the object o&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [5, 1, 2, 3, 5]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3, 5]&lt;/span&gt;

&lt;span class="c1"&gt;# pop(i) remove and return the object from position i&lt;/span&gt;
&lt;span class="c1"&gt;# pop() removes and returns the last element of the list&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3, 6, 5]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3, 5] and return 6&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3] and return 5&lt;/span&gt;

&lt;span class="c1"&gt;#index(o) returns the index of the object o&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# returns 2&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3, 3]&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# keeps returning 2 as it is the first occurrence of 3&lt;/span&gt;

&lt;span class="c1"&gt;# count(o) counts how many times the object o appears in the list&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# returns 1&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# returns 2&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3] and returns 3&lt;/span&gt;

&lt;span class="c1"&gt;# extend(L) extend list with list L&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [1, 2, 3, 0, -1, -2]&lt;/span&gt;

&lt;span class="c1"&gt;# sort() sorts the list items by itself&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [-2, -1, 0, 1, 2, 3]&lt;/span&gt;

&lt;span class="c1"&gt;# reverse() reverses the elements of the list on itself&lt;/span&gt;
&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# the list will look like this [3, 2, 1, 0, -1, -2]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Now it&amp;rsquo;s time to&amp;nbsp;exercise!&lt;/p&gt;
&lt;p&gt;Open the terminal, and start playing with the lists! See how the commands&amp;nbsp;work!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A tip! The &lt;code&gt;help&lt;/code&gt; command shows information about a command! try it after
creating a list l, the command:
    &amp;gt;&amp;gt;&amp;gt;&amp;nbsp;help(l.sort)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the next post we will talk about an operation that has everything to do with lists: List&amp;nbsp;Comprehension.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A&amp;nbsp;challenge!&lt;/p&gt;
&lt;p&gt;Who can imagine how to make a matrix in Python using what we saw&amp;nbsp;today?&lt;/p&gt;
&lt;p&gt;Leave your answer in the&amp;nbsp;comments!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Parte 7 - Estruturas de Dados - 1</title><link href="http://programeempython.com.br/python-101-parte-7.html" rel="alternate"></link><published>2022-08-11T00:29:00+02:00</published><updated>2022-08-11T00:29:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-11:/python-101-parte-7.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hoje vamos ver uma coisa muito importante no Python: as estruturas de dados&amp;nbsp;nativas.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Hoje vamos ver uma coisa muito importante no Python: as estruturas de dados&amp;nbsp;nativas.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;S&amp;atilde;o v&amp;aacute;rios os tipos de dados nativos do Python. Entre eles, os mais importantes, pois s&amp;atilde;o essenciais para qualquer programa, s&amp;atilde;o os&amp;nbsp;tipos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;int&lt;/code&gt; - n&amp;uacute;meros&amp;nbsp;inteiro&lt;/li&gt;
&lt;li&gt;&lt;code&gt;float&lt;/code&gt; - ponto flutuante, representando os n&amp;uacute;meros reais,&amp;nbsp;basicamente&lt;/li&gt;
&lt;li&gt;&lt;code&gt;string&lt;/code&gt; - cadeia de caracteres, ou basicamente,&amp;nbsp;texto&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Por&amp;eacute;m, em Python, diferente de outras linguagens, estes tipos de dados, assim como todas as outras estruturas da linguagem s&amp;atilde;o objetos, desta forma, o tipo b&amp;aacute;sico de tudo em python &amp;eacute; &lt;code&gt;object&lt;/code&gt;. H&amp;aacute; muito a se discutir sobre tipos de dados, mas para simplificar consideraremos&amp;nbsp;assim.&lt;/p&gt;
&lt;p&gt;Voltando &amp;agrave;s estruturas de dados nativas, veremos que estas s&amp;atilde;o conjuntos estruturados de objetos que podem conter elementos de qualquer outro&amp;nbsp;tipo.&lt;/p&gt;
&lt;p&gt;A primeira e talvez mais largamente usada destas estruturas &amp;eacute; a &lt;code&gt;list&lt;/code&gt;. Uma &lt;code&gt;list&lt;/code&gt; implementa uma lista que pode conter virtualmente qualquer objeto, sendo composta por quantos tipos de objeto for necess&amp;aacute;rio (diferente de algumas&amp;nbsp;linguagens).&lt;/p&gt;
&lt;p&gt;Desta forma, listas se tornam uma ferramenta muito poderosa dentro do Python. Teremos mais adiante um post focado especialmente nas listas e seus&amp;nbsp;m&amp;eacute;todos.&lt;/p&gt;
&lt;p&gt;Para criar uma lista, basta atribuir valores a ela da seguinte&amp;nbsp;forma:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Assim como fizemos quando vimos como funciona o &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Outra estrutura de dados muito importante e largamente usada &amp;eacute; a &lt;code&gt;tuple&lt;/code&gt; (tupla). Tuplas cont&amp;eacute;m conjuntos de valores assim como as listas, por&amp;eacute;m se diferenciam destas principalmente pelo fato de as tuplas n&amp;atilde;o poderem ser alteradas ap&amp;oacute;s sua cria&amp;ccedil;&amp;atilde;o, e as listas&amp;nbsp;sim.&lt;/p&gt;
&lt;p&gt;Vamos criar uma&amp;nbsp;tupla:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Vejamos agora uma das estruturas de dados mais poderosas do Python, e que possui muitas possibilidades de utiliza&amp;ccedil;&amp;atilde;o. Esta estrutura &amp;eacute; o &lt;code&gt;dict&lt;/code&gt; (dicion&amp;aacute;rio) que relaciona pares de chave e&amp;nbsp;valor.&lt;/p&gt;
&lt;p&gt;Assim criamos um&amp;nbsp;dicion&amp;aacute;rio:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'e'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Finalmente, a &amp;uacute;ltima estrutura de dados nativa do Python que veremos hoje &amp;eacute; o set (conjunto). Os sets representam conjuntos matem&amp;aacute;ticos. Assim, s&amp;atilde;o sequ&amp;ecirc;ncias e uma caracter&amp;iacute;stica interessante &amp;eacute; que n&amp;atilde;o possuem elementos&amp;nbsp;repetidos.&lt;/p&gt;
&lt;p&gt;Por exemplo, ao criar este&amp;nbsp;set:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;O conjunto ser&amp;aacute; &lt;code&gt;[1, 2, 3, 5, 7, 13, 17]&lt;/code&gt;, pois &lt;code&gt;1&lt;/code&gt; aparecia 2 vezes na lista original, e no set ele aparece somente uma&amp;nbsp;vez.&lt;/p&gt;
&lt;p&gt;Nos Pr&amp;oacute;ximos posts, vamos ver em mais detalhes estas estruturas de dados&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 7 - Data Structures - 1</title><link href="http://programeempython.com.br/python-101-parte-7-en.html" rel="alternate"></link><published>2022-08-11T00:29:00+02:00</published><updated>2022-08-11T00:29:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-11:/python-101-parte-7-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today we are going to look at a very important thing in Python: the native data&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repetition …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Today we are going to look at a very important thing in Python: the native data&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-6-en.html"&gt;Repetition Structures -&amp;nbsp;for&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are several native Python data types. Among them, the most important, as they are essential for any program, are the&amp;nbsp;types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;int&lt;/code&gt; -&amp;nbsp;integers&lt;/li&gt;
&lt;li&gt;&lt;code&gt;float&lt;/code&gt; - floating point, representing the real numbers,&amp;nbsp;basically&lt;/li&gt;
&lt;li&gt;&lt;code&gt;string&lt;/code&gt; - string, or basically,&amp;nbsp;text&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, in Python, unlike other languages, these data types, like all other structures in the language, are objects, so the basic type of everything in python is &lt;code&gt;object&lt;/code&gt;. There&amp;rsquo;s a lot to discuss about data types, but for simplicity&amp;rsquo;s sake we&amp;rsquo;ll consider it that&amp;nbsp;way.&lt;/p&gt;
&lt;p&gt;Returning to native data structures, we will see that these are structured sets of objects that can contain elements of any other&amp;nbsp;type.&lt;/p&gt;
&lt;p&gt;The first and perhaps most widely used of these structures is the &lt;code&gt;list&lt;/code&gt;. A &lt;code&gt;list&lt;/code&gt; implements a list that can contain virtually any object, consisting of as many object types as needed (unlike some&amp;nbsp;languages).&lt;/p&gt;
&lt;p&gt;In this way, lists become a very powerful tool within Python. We will have a post later focused especially on lists and their&amp;nbsp;methods.&lt;/p&gt;
&lt;p&gt;To create a list, simply assign values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;to it as&amp;nbsp;follows:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Just like we did when we saw how &lt;code&gt;for&lt;/code&gt; works.&lt;/p&gt;
&lt;p&gt;Another very important and widely used data structure is the &lt;code&gt;tuple&lt;/code&gt;. Tuples contain sets of values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;just like lists, but they differ from them mainly in that tuples cannot be changed after they are created, and lists&amp;nbsp;can.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s create a&amp;nbsp;tuple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Now let&amp;rsquo;s look at one of Python&amp;rsquo;s most powerful data structures, and one that has many possibilities for use. This structure is the &lt;code&gt;dict&lt;/code&gt; (dictionary) that relates key and value&amp;nbsp;pairs.&lt;/p&gt;
&lt;p&gt;So we create a&amp;nbsp;dictionary:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'e'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Finally, the last native Python data structure we&amp;rsquo;ll look at today is the set. The sets represent mathematical sets. Thus, they are sequences and an interesting feature is that they do not have repeated&amp;nbsp;elements.&lt;/p&gt;
&lt;p&gt;For example, when creating this&amp;nbsp;set:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;The set will be &lt;code&gt;[1, 2, 3, 5, 7, 13, 17]&lt;/code&gt;, as &lt;code&gt;1&lt;/code&gt; appeared twice in the original list, and in the set it appears only&amp;nbsp;once.&lt;/p&gt;
&lt;p&gt;In the next posts, we will see these data structures in more detail&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;Until the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Parte 6 - Estruturas de Repetição - For</title><link href="http://programeempython.com.br/python-101-parte-6.html" rel="alternate"></link><published>2022-08-09T12:06:00+02:00</published><updated>2022-08-09T12:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-09:/python-101-parte-6.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Mais um post aqui ensinando Python para voc&amp;ecirc;s e hoje veremos o &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vamos come&amp;ccedil;ar com um exemplo …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Mais um post aqui ensinando Python para voc&amp;ecirc;s e hoje veremos o &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5.html"&gt;Estruturas de Repeti&amp;ccedil;&amp;atilde;o -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Vamos come&amp;ccedil;ar com um exemplo&amp;nbsp;simples:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Aqui, inicialmente, come&amp;ccedil;amos com algo que ainda n&amp;atilde;o vimos: &lt;strong&gt;listas&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Come&amp;ccedil;amos criando &lt;code&gt;l&lt;/code&gt; como uma lista que cont&amp;eacute;m uma sequ&amp;ecirc;ncia de&amp;nbsp;n&amp;uacute;meros.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, esta lista &amp;eacute; usada dentro do &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Em outras linguagens, determinamos o valor inicial da vari&amp;aacute;vel contadora, seu limite e o passo de itera&amp;ccedil;&amp;atilde;o. Em python isso n&amp;atilde;o acontece. Aqui, o for somente itera sobre sequ&amp;ecirc;ncias. Isto traz v&amp;aacute;rias vantagens, como por exemplo, iterar sobre strings, ou listas de elementos&amp;nbsp;variados.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Ser&amp;aacute; mostrado adiante porque este for n&amp;atilde;o est&amp;aacute; em desvantagem frente ao for das outras&amp;nbsp;linguagens.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, a cada itera&amp;ccedil;&amp;atilde;o, a vari&amp;aacute;vel de itera&amp;ccedil;&amp;atilde;o, neste caso &lt;code&gt;i&lt;/code&gt;, recebe o elemento de uma posi&amp;ccedil;&amp;atilde;o da&amp;nbsp;lista.&lt;/p&gt;
&lt;p&gt;Assim, este trecho acima imprime na tela todos os valores contidos na lista &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Vamos ver agora este trecho de&amp;nbsp;c&amp;oacute;digo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'arroz'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'feij&amp;atilde;o'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'carne'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'batata'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Estou cozinhando '&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Este exemplo demonstra a utiliza&amp;ccedil;&amp;atilde;o do &lt;code&gt;for&lt;/code&gt; com listas que cont&amp;eacute;m &lt;em&gt;strings&lt;/em&gt;, mostrando que pode-se usar listas com qualquer objeto num &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;No &lt;code&gt;for&lt;/code&gt; tamb&amp;eacute;m podemos usar &lt;code&gt;break&lt;/code&gt; e &lt;code&gt;continue&lt;/code&gt;. Assim, podemos controlar ainda mais o comportamento do la&amp;ccedil;o. Al&amp;eacute;m disso, h&amp;aacute; uma caracter&amp;iacute;stica no &lt;code&gt;for&lt;/code&gt; do Python que o deixa muito poderoso: podemos usar um &lt;code&gt;else&lt;/code&gt; ao final do &lt;code&gt;for&lt;/code&gt; como no exemplo a&amp;nbsp;seguir:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'e'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'f'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'g'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'h'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'"h" n&amp;atilde;o est&amp;aacute; na lista mas eu printo mesmo assim'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Usando o &lt;code&gt;else&lt;/code&gt; no final, podemos controlar o que ser&amp;aacute; executado ao final de um execu&amp;ccedil;&amp;atilde;o completa do &lt;code&gt;for&lt;/code&gt; e o que ser&amp;aacute; executado se o la&amp;ccedil;o for quebrado por um &lt;code&gt;break&lt;/code&gt;. Quando o la&amp;ccedil;o &amp;eacute; completamente percorrido sem uma quebra, a execu&amp;ccedil;&amp;atilde;o segue pra dentro do &lt;code&gt;else&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;Neste exemplo, a sa&amp;iacute;da ser&amp;aacute; algo&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;a
b
c
d
e
f
g
"h" n&amp;atilde;o est&amp;aacute; na lista mas eu printo mesmo assim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto &amp;eacute; muito importante, pois evita que tenhamos que fazer testes complicados para detectar quando um &lt;code&gt;for&lt;/code&gt; for quebrado por um &lt;code&gt;break&lt;/code&gt; que ser&amp;aacute; chamado em condi&amp;ccedil;&amp;otilde;es&amp;nbsp;complexas.&lt;/p&gt;
&lt;p&gt;Finalmente, muitos devem estar se perguntando: &amp;ldquo;Como este &lt;code&gt;for&lt;/code&gt; pode ser t&amp;atilde;o poderoso se temos que definir as listas&amp;nbsp;manualmente?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;O fato &amp;eacute; que n&amp;atilde;o temos que fazer manualmente se for uma lista de n&amp;uacute;meros (assim como n&amp;atilde;o precisamos em outras&amp;nbsp;linguagens).&lt;/p&gt;
&lt;p&gt;Existe uma fun&amp;ccedil;&amp;atilde;o em Python, range, que retorna uma &lt;em&gt;generator&lt;/em&gt; (objeto que pode ser iterado como uma lista, mas gera os valores durante a execu&amp;ccedil;&amp;atilde;o) de n&amp;uacute;meros no intervalo especificado. Veja o&amp;nbsp;exemplo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&amp;eacute; par'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&amp;eacute; impar'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Quando fazemos range(50), teremos uma &lt;em&gt;generator&lt;/em&gt; que funcionar&amp;aacute; como uma lista de inteiros de 0 a 49. (experimente no&amp;nbsp;shell).&lt;/p&gt;
&lt;p&gt;Bem, pessoal! Por hoje &amp;eacute;&amp;nbsp;isso!&lt;/p&gt;
&lt;p&gt;Agora falta pouco para iniciarmos uma programa&amp;ccedil;&amp;atilde;o efetiva em&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;Nos Pr&amp;oacute;ximos Posts, tipos de dados nativos do&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 6 - Repetition Structures - For</title><link href="http://programeempython.com.br/python-101-parte-6-en.html" rel="alternate"></link><published>2022-08-09T12:06:00+02:00</published><updated>2022-08-09T12:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-09:/python-101-parte-6-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;One more post here teaching you Python and today we will talk about &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s start with …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;One more post here teaching you Python and today we will talk about &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-5-en.html"&gt;Repetition Structures -&amp;nbsp;while&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s start with a simple&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Here, initially, we start with something we haven&amp;rsquo;t seen yet: &lt;strong&gt;lists&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We start by creating &lt;code&gt;l&lt;/code&gt; as a list that contains a sequence of&amp;nbsp;numbers.&lt;/p&gt;
&lt;p&gt;So this list is used inside the &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In other languages, we determine the initial value of the counter variable, its limit and the iteration step. In python this does not happen. Here, for only iterates over sequences. This has several advantages, such as iterating over strings, or lists of different&amp;nbsp;elements.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;It will be shown later because this for is not at a disadvantage compared to the for of other&amp;nbsp;languages.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Then, at each iteration, the iteration variable, in this case &lt;code&gt;i&lt;/code&gt;, receives the element of a position in the&amp;nbsp;list.&lt;/p&gt;
&lt;p&gt;Thus, this snippet above prints on the screen all the values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;contained in the list &lt;code&gt;l&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s see this code&amp;nbsp;snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'rice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'beans'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'meat'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'potato'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'I'&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;cooking&lt;/span&gt; &lt;span class="s1"&gt;', i)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;This example demonstrates the use of &lt;code&gt;for&lt;/code&gt; with lists that contain &lt;em&gt;strings&lt;/em&gt;, showing that you can use lists with any object in a &lt;code&gt;for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In &lt;code&gt;for&lt;/code&gt; we can also use &lt;code&gt;break&lt;/code&gt; and &lt;code&gt;continue&lt;/code&gt;. Thus, we can further control the behavior of the loop. Also, there is a feature in Python&amp;rsquo;s &lt;code&gt;for&lt;/code&gt; that makes it very powerful: we can use an &lt;code&gt;else&lt;/code&gt; at the end of the &lt;code&gt;for&lt;/code&gt; as in the following&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'e'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;&amp;ZeroWidthSpace;&amp;ZeroWidthSpace;&lt;/span&gt;&lt;span class="s1"&gt;'f'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'g'&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'h'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'"h" is not in the list but I print anyway'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Using &lt;code&gt;else&lt;/code&gt; at the end, we can control what will be executed at the end of a complete &lt;code&gt;for&lt;/code&gt; execution and what will be executed if the loop is broken by a &lt;code&gt;break&lt;/code&gt;. When the loop is completely traversed without a break, execution proceeds into &lt;code&gt;else&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;In this example, the output will look something like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;a
b
c
d
e
f
g
"h" is not in the list but I print it anyway
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is very important, as it avoids having to do complicated tests to detect when a &lt;code&gt;for&lt;/code&gt; is broken by a &lt;code&gt;break&lt;/code&gt; that will be called under complex&amp;nbsp;conditions.&lt;/p&gt;
&lt;p&gt;Finally, many may be wondering: &amp;ldquo;How can this &lt;code&gt;for&lt;/code&gt; be so powerful if we have to define the lists&amp;nbsp;manually?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The fact is that we don&amp;rsquo;t have to do it manually if it&amp;rsquo;s a list of numbers (just like we don&amp;rsquo;t need to in other&amp;nbsp;languages).&lt;/p&gt;
&lt;p&gt;There is a Python function, range, which returns a &lt;em&gt;generator&lt;/em&gt; (object that can be iterated over like a list, but generates the values &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;at runtime) of numbers in the specified range. See the&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'is even'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'is odd'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;When we do range(50), we will have a &lt;em&gt;generator&lt;/em&gt; that will work as a list of integers from 0 to 49. (try it in the&amp;nbsp;shell).&lt;/p&gt;
&lt;p&gt;Well folks! That&amp;rsquo;s it for&amp;nbsp;today!&lt;/p&gt;
&lt;p&gt;Now it&amp;rsquo;s not long before we start effective programming in&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;In the next posts, native Python data&amp;nbsp;types!&lt;/p&gt;
&lt;p&gt;Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Tutorial de Pelican com Github Pages e CircleCI - 2</title><link href="http://programeempython.com.br/tutorial-pelican-2.html" rel="alternate"></link><published>2022-08-08T09:30:00+02:00</published><updated>2022-08-08T09:30:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-08:/tutorial-pelican-2.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Chegou a hora de continuarmos o tutorial de como publicar seu blog com Pelican, Github Pages e Circle &lt;span class="caps"&gt;CI&lt;/span&gt; como eu fiz, e caso voc&amp;ecirc; esteja chegando por aqui agora, confira nossos tutoriais&amp;nbsp;anteriores&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican.html"&gt;Tutorial Inicial de Pelican&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1.html"&gt;Tutorial b&amp;aacute;sico de &lt;span class="caps"&gt;GIT&lt;/span&gt; e&amp;nbsp;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hoje vamos falar sobre Github …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Chegou a hora de continuarmos o tutorial de como publicar seu blog com Pelican, Github Pages e Circle &lt;span class="caps"&gt;CI&lt;/span&gt; como eu fiz, e caso voc&amp;ecirc; esteja chegando por aqui agora, confira nossos tutoriais&amp;nbsp;anteriores&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican.html"&gt;Tutorial Inicial de Pelican&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1.html"&gt;Tutorial b&amp;aacute;sico de &lt;span class="caps"&gt;GIT&lt;/span&gt; e&amp;nbsp;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hoje vamos falar sobre Github&amp;nbsp;Pages.&lt;/p&gt;
&lt;p&gt;Github Pages &amp;eacute; uma funcionalidade gratuita do Github que te permite criar um site est&amp;aacute;tico para seu perfil ou para seus projetos. Geralmente estes sites ter&amp;atilde;o uma &lt;span class="caps"&gt;URL&lt;/span&gt; do tipo &lt;code&gt;usuario.github.io&lt;/code&gt; ou &lt;code&gt;projeto.github.io&lt;/code&gt;. Por&amp;eacute;m, &amp;eacute; poss&amp;iacute;vel tamb&amp;eacute;m colocar seu pr&amp;oacute;prio dom&amp;iacute;nio, como fiz&amp;nbsp;aqui.&lt;/p&gt;
&lt;p&gt;Para este tutorial, vamos usar o github pages para seu usu&amp;aacute;rio, assim, crie um reposit&amp;oacute;rio chamado &lt;code&gt;username.github.io&lt;/code&gt;, onde username &amp;eacute; seu nome de&amp;nbsp;usu&amp;aacute;rio.&lt;/p&gt;
&lt;p&gt;No canto superior direito do site clique no &lt;code&gt;+&lt;/code&gt; e selecione &lt;code&gt;New Repository&lt;/code&gt;. O nome deve ser na forma &lt;code&gt;username.github.io&lt;/code&gt;, como disse&amp;nbsp;acima. &lt;/p&gt;
&lt;p&gt;&lt;img alt="New Repository Github" src="/images/githubAddRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;Agora, vamos clonar o reposit&amp;oacute;rio. Se voc&amp;ecirc; nunca usou git ou github antes, o &lt;a href="({filename}/Tutoriais/git-github.md)"&gt;tutorial listado acima&lt;/a&gt; &amp;eacute; essencial para&amp;nbsp;continuar.&lt;/p&gt;
&lt;p&gt;Copie o link &lt;span class="caps"&gt;SSH&lt;/span&gt; para clonar seu reposit&amp;oacute;rio, e execute o&amp;nbsp;comando:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="nv"&gt;@github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto vai criar uma pasta chamada &lt;code&gt;username.github.io&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Entre na pasta, e vamos criar um arquivo chamado index.html, e este ter&amp;aacute; o seguinte&amp;nbsp;conte&amp;uacute;do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Ol&amp;aacute;! Github Pages &amp;eacute; muito legal!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Em seguida vamos fazer commit e push deste arquivo para nosso&amp;nbsp;reposit&amp;oacute;rio.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git add .
git commit -m "primeiro commit"
git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora no github, na p&amp;aacute;gina do seu reposit&amp;oacute;rio, vamos clicar em &lt;code&gt;Settings&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Repository Settings" src="/images/gitHubRepoSetting.png"/&gt;&lt;/p&gt;
&lt;p&gt;No menu lateral, na sess&amp;atilde;o &lt;code&gt;Code and Automation&lt;/code&gt; selecione &lt;code&gt;Pages&lt;/code&gt;. Ent&amp;atilde;o, em &lt;code&gt;Branch&lt;/code&gt; selecione &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github repo settings pages" src="/images/githubsettingsbranch.png"/&gt;&lt;/p&gt;
&lt;p&gt;Clique no bot&amp;atilde;o &lt;code&gt;Save&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Aguarde um tempo, geralmente menos de 1 minuto, e sua p&amp;aacute;gina do Github Pages estar&amp;aacute; no ar! Muito f&amp;aacute;cil,&amp;nbsp;n&amp;atilde;o?&lt;/p&gt;
&lt;p&gt;&lt;img alt="Primeira p&amp;aacute;gina do Github Pages" src="/images/githubPagesFirst.png"/&gt;&lt;/p&gt;
&lt;p&gt;No pr&amp;oacute;ximo post vamos juntar Pelican e Github Pages e estaremos mais pr&amp;oacute;ximos de ter nosso blog pronto para publicar&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;Espero que tenham gostado e n&amp;atilde;o esque&amp;ccedil;am de deixar suas opini&amp;otilde;es e d&amp;uacute;vidas nos&amp;nbsp;coment&amp;aacute;rios!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Pelican Tutorial with Github Pages and CircleCI - 2</title><link href="http://programeempython.com.br/tutorial-pelican-2-en.html" rel="alternate"></link><published>2022-08-08T09:30:00+02:00</published><updated>2022-08-08T09:30:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-08:/tutorial-pelican-2-en.html</id><summary type="html">&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s time for us to continue the tutorial on how to publish your blog with Pelican, Github Pages and Circle &lt;span class="caps"&gt;CI&lt;/span&gt; like I did, and in case you&amp;rsquo;re getting here now, check out our previous&amp;nbsp;tutorials&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-en.html"&gt;Starter Pelican Tutorial&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1-en.html"&gt;Basic &lt;span class="caps"&gt;GIT&lt;/span&gt; and GitHub&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Today we are …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s time for us to continue the tutorial on how to publish your blog with Pelican, Github Pages and Circle &lt;span class="caps"&gt;CI&lt;/span&gt; like I did, and in case you&amp;rsquo;re getting here now, check out our previous&amp;nbsp;tutorials&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-pelican-en.html"&gt;Starter Pelican Tutorial&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/tutorial-git-1-en.html"&gt;Basic &lt;span class="caps"&gt;GIT&lt;/span&gt; and GitHub&amp;nbsp;Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Today we are going to talk about Github&amp;nbsp;Pages.&lt;/p&gt;
&lt;p&gt;Github Pages is a free feature of Github that allows you to create a static website for your profile or projects. Usually these sites will have a &lt;span class="caps"&gt;URL&lt;/span&gt; like &lt;code&gt;user.github.io&lt;/code&gt; or &lt;code&gt;project.github.io&lt;/code&gt;. However, you can also put your own domain, as I did&amp;nbsp;here.&lt;/p&gt;
&lt;p&gt;For this tutorial, we&amp;rsquo;re going to use github pages for your user, so create a repository called &lt;code&gt;username.github.io&lt;/code&gt;, where username is your&amp;nbsp;username.&lt;/p&gt;
&lt;p&gt;In the upper right corner of the site click on the &lt;code&gt;+&lt;/code&gt; and select &lt;code&gt;New Repository&lt;/code&gt;. The name must be in the form &lt;code&gt;username.github.io&lt;/code&gt;, as said&amp;nbsp;above.&lt;/p&gt;
&lt;p&gt;&lt;img alt="New Github Repository" src="/images/githubAddRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;Now, let&amp;rsquo;s clone the repository. If you&amp;rsquo;ve never used git or github before, the &lt;a href="({filename}/Tutoriais/en/git-github.md)"&gt;tutorial listed above&lt;/a&gt; is essential to&amp;nbsp;continue.&lt;/p&gt;
&lt;p&gt;Copy the &lt;span class="caps"&gt;SSH&lt;/span&gt; link to clone your repository, and run the&amp;nbsp;command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="nv"&gt;@github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will create a folder called &lt;code&gt;username.github.io&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Enter the folder, and we will create a file called index.html, and this will have the following&amp;nbsp;content:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello! Github Pages is really cool!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Next we will commit and push this file to our&amp;nbsp;repository.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git add .
git commit -m "first commit"
git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now on github, on your repository page, let&amp;rsquo;s click on &lt;code&gt;Settings&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Repository Settings" src="/images/gitHubRepoSetting.png"/&gt;&lt;/p&gt;
&lt;p&gt;In the side menu, in the &lt;code&gt;Code and Automation&lt;/code&gt; section select &lt;code&gt;Pages&lt;/code&gt;. Then in &lt;code&gt;Branch&lt;/code&gt; select &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github repo settings pages" src="/images/githubsettingsbranch.png"/&gt;&lt;/p&gt;
&lt;p&gt;Click on the &lt;code&gt;Save&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;Wait for a while, usually less than 1 minute, and your Github Pages page will be live! Very easy,&amp;nbsp;no?&lt;/p&gt;
&lt;p&gt;&lt;img alt="First page of Github Pages" src="/images/githubPagesFirstEN.png"/&gt;&lt;/p&gt;
&lt;p&gt;In the next post we will join Pelican and Github Pages and we will be closer to having our blog ready to publish&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;I hope you liked it and don&amp;rsquo;t forget to leave your opinions and questions in the&amp;nbsp;comments!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Python 101 - Parte 5 - Estruturas de Repetição - While</title><link href="http://programeempython.com.br/python-101-parte-5.html" rel="alternate"></link><published>2022-08-07T22:11:00+02:00</published><updated>2022-08-07T22:11:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-07:/python-101-parte-5.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Vamos continuar falando sobre Programa&amp;ccedil;&amp;atilde;o B&amp;aacute;sica no Python! Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hoje vamos falar de uma das estruturas mais importantes: o &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;O &lt;code&gt;while&lt;/code&gt; &amp;eacute; …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Vamos continuar falando sobre Programa&amp;ccedil;&amp;atilde;o B&amp;aacute;sica no Python! Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Hoje vamos falar de uma das estruturas mais importantes: o &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;O &lt;code&gt;while&lt;/code&gt; &amp;eacute; um comando que manda um bloco de c&amp;oacute;digo ser executado enquanto uma condi&amp;ccedil;&amp;atilde;o for satisfeita. Assim, permite que sejam criados loops de execu&amp;ccedil;&amp;atilde;o, assim como temos em jogos e aplicativos com interfaces&amp;nbsp;gr&amp;aacute;ficas.&lt;/p&gt;
&lt;p&gt;O &lt;code&gt;while&lt;/code&gt; &amp;eacute; um comando muito &amp;uacute;til, mas pode ser perigoso, pois se n&amp;atilde;o tratarmos corretamente o crit&amp;eacute;rio de parada, o la&amp;ccedil;o pode n&amp;atilde;o ter fim, e o programa n&amp;atilde;o faz o que&amp;nbsp;deveria.&lt;/p&gt;
&lt;p&gt;Vamos ver ent&amp;atilde;o um exemplo de como funciona o &lt;code&gt;while&lt;/code&gt; em&amp;nbsp;Python:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x &amp;gt; 0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Neste c&amp;oacute;digo, ser&amp;aacute; mostrada a mensagem &lt;code&gt;x &amp;gt; 0&lt;/code&gt; at&amp;eacute; que x seja igual a zero. Quando o valor de &lt;code&gt;x&lt;/code&gt; passar para &lt;code&gt;0&lt;/code&gt;, a verifica&amp;ccedil;&amp;atilde;o &lt;code&gt;x&amp;gt;0&lt;/code&gt; retornar&amp;aacute; falso, o programa sai do&amp;nbsp;la&amp;ccedil;o.&lt;/p&gt;
&lt;p&gt;Vejamos agora este trecho de&amp;nbsp;c&amp;oacute;digo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"N&amp;atilde;o vou parar nunca!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Aqui temos um la&amp;ccedil;o que seria executado eternamente (&lt;code&gt;while True:&lt;/code&gt;). Por&amp;eacute;m, dentro dele, fazemos uma verifica&amp;ccedil;&amp;atilde;o, e quando a vari&amp;aacute;vel &lt;code&gt;i&lt;/code&gt; estiver guardando um valor maior que &lt;code&gt;100&lt;/code&gt;, ser&amp;aacute; executado o comando &lt;code&gt;break&lt;/code&gt;. O comando &lt;code&gt;break&lt;/code&gt; literalmente quebra o la&amp;ccedil;o, ent&amp;atilde;o, naquele instante, o programa sai do&amp;nbsp;la&amp;ccedil;o.&lt;/p&gt;
&lt;p&gt;Se logo abaixo deste c&amp;oacute;digo fiz&amp;eacute;ssemos um &lt;code&gt;print(i)&lt;/code&gt;, o valor mostrado seria &lt;code&gt;100&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Assim, juntamente ao comando &lt;code&gt;while&lt;/code&gt;, vimos agora o comando &lt;code&gt;break&lt;/code&gt; que pode ser muito &amp;uacute;til para quebrar la&amp;ccedil;os fora da compara&amp;ccedil;&amp;atilde;o&amp;nbsp;padr&amp;atilde;o.&lt;/p&gt;
&lt;p&gt;Vejamos agora o seguinte&amp;nbsp;trecho:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Inicialmente, &lt;code&gt;i&lt;/code&gt; recebe o valor &lt;code&gt;0&lt;/code&gt;, e &amp;eacute; comparado com &lt;code&gt;100&lt;/code&gt;. Como &lt;code&gt;0&lt;/code&gt; &amp;eacute; menor que &lt;code&gt;100&lt;/code&gt;, o la&amp;ccedil;o come&amp;ccedil;a. Logo em seguida, ap&amp;oacute;s incrementarmos o valor de &lt;code&gt;i&lt;/code&gt;, temos uma compara&amp;ccedil;&amp;atilde;o: if &lt;code&gt;1%2 == 0:&lt;/code&gt;. aqui verificamos se &lt;code&gt;i&lt;/code&gt; &amp;eacute; m&amp;uacute;ltiplo de &lt;code&gt;2&lt;/code&gt;. Caso &lt;code&gt;i&lt;/code&gt; seja m&amp;uacute;ltiplo de dois, h&amp;aacute; um comando &lt;code&gt;continue&lt;/code&gt;. &lt;code&gt;continue&lt;/code&gt; faz com que esta itera&amp;ccedil;&amp;atilde;o do la&amp;ccedil;o termine e o programa passe para a pr&amp;oacute;xima itera&amp;ccedil;&amp;atilde;o. Desta forma, o programa ignora tudo o que est&amp;aacute; ap&amp;oacute;s o &lt;code&gt;continue&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;No caso de &lt;code&gt;i&lt;/code&gt; n&amp;atilde;o ser m&amp;uacute;ltiplo de &lt;code&gt;2&lt;/code&gt;, o programa n&amp;atilde;o executa o &lt;code&gt;continue&lt;/code&gt;, e imprime o valor de &lt;code&gt;i&lt;/code&gt; na&amp;nbsp;tela.&lt;/p&gt;
&lt;p&gt;Se um &lt;code&gt;continue&lt;/code&gt; estivesse fora do &lt;code&gt;if&lt;/code&gt;, sempre o programa executaria este &lt;code&gt;continue&lt;/code&gt;, e nunca seria executado o que h&amp;aacute; ap&amp;oacute;s ele. Assim, o &lt;code&gt;continue&lt;/code&gt; controla a execu&amp;ccedil;&amp;atilde;o do la&amp;ccedil;o sem&amp;nbsp;quebr&amp;aacute;-lo.&lt;/p&gt;
&lt;p&gt;Por enquanto &amp;eacute;&amp;nbsp;isso.&lt;/p&gt;
&lt;p&gt;Nosso pr&amp;oacute;ximo post vai falar sobre a instru&amp;ccedil;&amp;atilde;o&amp;nbsp;for.&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 5 - Repetition Structures - While</title><link href="http://programeempython.com.br/python-101-parte-5-en.html" rel="alternate"></link><published>2022-08-07T22:11:00+02:00</published><updated>2022-08-07T22:11:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-07:/python-101-parte-5-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s keep talking about Basic Programming in Python! In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Today we are going to talk about one of the most important …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s keep talking about Basic Programming in Python! In case you haven&amp;rsquo;t seen the previous tutorials, we already&amp;nbsp;have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introduction to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Python Code&amp;nbsp;Blocks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-4-en.html"&gt;Conditional Structures in Python -&amp;nbsp;2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Today we are going to talk about one of the most important structures: the &lt;code&gt;while&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;while&lt;/code&gt; is a statement that tells a block of code to be executed while a condition is satisfied. Thus, it allows execution loops to be created, as we have in games and applications with graphical&amp;nbsp;interfaces.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;while&lt;/code&gt; is a very useful statement, but it can be dangerous, because if we don&amp;rsquo;t handle the stopping criterion correctly, the loop may never end, and the program doesn&amp;rsquo;t do what it&amp;nbsp;should.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s see an example of how &lt;code&gt;while&lt;/code&gt; works in&amp;nbsp;Python:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x &amp;gt; 0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;In this code, the message &lt;code&gt;x &amp;gt; 0&lt;/code&gt; will be displayed until x is equal to zero. When the value of &lt;code&gt;x&lt;/code&gt; goes to &lt;code&gt;0&lt;/code&gt;, the check &lt;code&gt;x&amp;gt;0&lt;/code&gt; will return false, the program exits the&amp;nbsp;loop.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s look at this code&amp;nbsp;snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"I will never stop!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Here we have a loop that would run forever (&lt;code&gt;while True:&lt;/code&gt;). However, inside it, we do a check, and when the &lt;code&gt;i&lt;/code&gt; variable is storing a value greater than &lt;code&gt;100&lt;/code&gt;, the &lt;code&gt;break&lt;/code&gt; command will be executed. The &lt;code&gt;break&lt;/code&gt; command literally breaks the loop, so at that instant, the program exits the&amp;nbsp;loop.&lt;/p&gt;
&lt;p&gt;If just below this code we did a &lt;code&gt;print(i)&lt;/code&gt;, the value displayed would be &lt;code&gt;100&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So, along with the &lt;code&gt;while&lt;/code&gt; command, we have now seen the &lt;code&gt;break&lt;/code&gt; command which can be very useful for breaking loops outside the standard&amp;nbsp;comparison.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s look at the following&amp;nbsp;snippet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;continues&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Initially, &lt;code&gt;i&lt;/code&gt; is assigned the value &lt;code&gt;0&lt;/code&gt;, and is compared to &lt;code&gt;100&lt;/code&gt;. As &lt;code&gt;0&lt;/code&gt; is less than &lt;code&gt;100&lt;/code&gt;, the loop starts. Soon after, after incrementing the value of &lt;code&gt;i&lt;/code&gt;, we have a comparison: if &lt;code&gt;1%2 == 0:&lt;/code&gt;. here we check if &lt;code&gt;i&lt;/code&gt; is a multiple of &lt;code&gt;2&lt;/code&gt;. If &lt;code&gt;i&lt;/code&gt; is a multiple of two, there is a &lt;code&gt;continue&lt;/code&gt; command. &lt;code&gt;continue&lt;/code&gt; causes this iteration of the loop to end and the program moves on to the next iteration. This way, the program ignores everything after &lt;code&gt;continue&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In case &lt;code&gt;i&lt;/code&gt; is not a multiple of &lt;code&gt;2&lt;/code&gt;, the program does not execute &lt;code&gt;continue&lt;/code&gt;, and prints the value of &lt;code&gt;i&lt;/code&gt; on the&amp;nbsp;screen.&lt;/p&gt;
&lt;p&gt;If a &lt;code&gt;continue&lt;/code&gt; were outside the &lt;code&gt;if&lt;/code&gt;, the program would always execute this &lt;code&gt;continue&lt;/code&gt;, and the one after it would never be executed. Thus, &lt;code&gt;continue&lt;/code&gt; controls the execution of the loop without breaking&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s it for&amp;nbsp;now.&lt;/p&gt;
&lt;p&gt;Our next post will talk about the for&amp;nbsp;statement.&lt;/p&gt;
&lt;p&gt;Be sure to post questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Tutorial de Git e Github</title><link href="http://programeempython.com.br/tutorial-git-1.html" rel="alternate"></link><published>2022-08-07T10:02:00+02:00</published><updated>2022-08-07T10:02:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-07:/tutorial-git-1.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Eu estava escrevendo a continua&amp;ccedil;&amp;atilde;o do tutorial de pelican quando percebi que para falar de github pages, primeiro &amp;eacute; importante falar de git e github para ter certeza que estamos todos alinhados mais&amp;nbsp;adiante.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, o que &amp;eacute; &lt;span class="caps"&gt;GIT&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Git &amp;eacute; um sistema de gerenciamento de vers&amp;otilde;es de c&amp;oacute;digo …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Eu estava escrevendo a continua&amp;ccedil;&amp;atilde;o do tutorial de pelican quando percebi que para falar de github pages, primeiro &amp;eacute; importante falar de git e github para ter certeza que estamos todos alinhados mais&amp;nbsp;adiante.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, o que &amp;eacute; &lt;span class="caps"&gt;GIT&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Git &amp;eacute; um sistema de gerenciamento de vers&amp;otilde;es de c&amp;oacute;digo, ou seja, ele &amp;eacute; usado para controlarmos altera&amp;ccedil;&amp;otilde;es no c&amp;oacute;digo e &amp;eacute; especialmente &amp;uacute;til quando trabalhamos em colabora&amp;ccedil;&amp;atilde;o, seja num time centralizado ou de forma distribu&amp;iacute;da como acontece com projetos open source, por&amp;nbsp;exemplo.&lt;/p&gt;
&lt;p&gt;Vou deixar aqui a p&amp;aacute;gina oficial onde voc&amp;ecirc; pode ver como &lt;a href="https://git-scm.com/book/pt-br/v2/Come%C3%A7ando-Instalando-o-Git"&gt;instalar o &lt;span class="caps"&gt;GIT&lt;/span&gt;&lt;/a&gt;. Se voc&amp;ecirc; usa Windows, recomendo que use &lt;code&gt;Git Bash&lt;/code&gt;, que faz parte da instala&amp;ccedil;o oficial, para interagir com reposit&amp;oacute;rios &lt;span class="caps"&gt;GIT&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Dado que agora voc&amp;ecirc; tem git instalado no seu computador, vamos configurar seu&amp;nbsp;github.&lt;/p&gt;
&lt;p&gt;Crie sua conta no &lt;a href="https://github.com"&gt;github&lt;/a&gt;, caso ainda n&amp;atilde;o&amp;nbsp;tenha.&lt;/p&gt;
&lt;p&gt;No seu computador abra o terminal onde voc&amp;ecirc; usa o git. Vamos aqui gerar uma chave &lt;span class="caps"&gt;SSH&lt;/span&gt; para autenticar no github de forma segura. Entre o&amp;nbsp;comando:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ssh-keygen
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Voc&amp;ecirc; pode simplesmente usar as op&amp;ccedil;&amp;otilde;es padr&amp;atilde;o. Elas n&amp;atilde;o s&amp;atilde;o as mais seguras mas acredito que sejam suficientes para in&amp;iacute;cio de conversa. Se voc&amp;ecirc; prover uma senha para sua chave &lt;span class="caps"&gt;SSH&lt;/span&gt;, ter&amp;aacute; de us&amp;aacute;-la sempre que for usar o acesso ao github no terminal, por&amp;nbsp;exemplo.&lt;/p&gt;
&lt;p&gt;Ap&amp;oacute;s executar este comando, voc&amp;ecirc; ter&amp;aacute; criado um par de arquivos na pasta &lt;code&gt;.ssh&lt;/code&gt; na sua pasta de usu&amp;aacute;rio. Estes s&amp;oelig; &lt;code&gt;id_rsa&lt;/code&gt; e &lt;code&gt;id_rsa.pub&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Vamos precisar do conte&amp;uacute;do do arquivo &lt;code&gt;id_rsa.pub&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Agora, na sua p&amp;aacute;gina do gihub, clique no &amp;iacute;cone do seu usu&amp;aacute;rio (canto superior direito da p&amp;aacute;gina) e nas op&amp;ccedil;&amp;otilde;es, selecione &lt;code&gt;Settings&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github User Settings" src="/images/githubUserMenu.png"/&gt;&lt;/p&gt;
&lt;p&gt;Ali, em &lt;code&gt;Access&lt;/code&gt; selecione &lt;code&gt;SSH and GPG keys&lt;/code&gt;. Clique no bot&amp;atilde;o &lt;code&gt;New SSH Key&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Add SSH" src="/images/githubAddSSH.png"/&gt;&lt;/p&gt;
&lt;p&gt;Copie o conte&amp;uacute;do do arquivo &lt;code&gt;id_rsa.pub&lt;/code&gt; e cole em &lt;code&gt;Key&lt;/code&gt;, D&amp;ecirc; algum nome relevante e&amp;nbsp;salve.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Save SSH" src="/images/githubSaveKey.png"/&gt;&lt;/p&gt;
&lt;p&gt;Agora seu github est&amp;aacute;&amp;nbsp;configurado.&lt;/p&gt;
&lt;p&gt;Crie ent&amp;atilde;o um reposit&amp;aring;orio no github atraves do bot&amp;atilde;o &lt;code&gt;+&lt;/code&gt; no canto superior direito ao lado do menu de&amp;nbsp;usu&amp;aacute;rio.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github cria reposit&amp;oacute;rio" src="/images/githubCriaRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;Voc&amp;ecirc; ver&amp;aacute; uma p&amp;aacute;gina com instru&amp;ccedil;&amp;otilde;es de como clonar seu reposit&amp;oacute;rio. Selecione a op&amp;ccedil;&amp;atilde;o &lt;span class="caps"&gt;SSH&lt;/span&gt; ecopie o&amp;nbsp;link.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github clona Repo" src="/images/githubCloneRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;No terminal,&amp;nbsp;gigite:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="nv"&gt;@github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;repositorui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Onde voc&amp;ecirc; vai substituir o &lt;code&gt;git@github.com:username/repositorui.git&lt;/code&gt; pela &lt;span class="caps"&gt;URL&lt;/span&gt; que copiou do github. Ela deve ter este formato tamb&amp;eacute;m, come&amp;ccedil;ando com &lt;code&gt;git@github.com&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Entre na pasta criada e crie um arquivo, pode ter qualquer nome, como &lt;span class="caps"&gt;README&lt;/span&gt;.md por exemplo e escreva algo&amp;nbsp;nele.&lt;/p&gt;
&lt;p&gt;Agora voc&amp;ecirc; precisa informar ao git que ele deve guardar as mudan&amp;ccedil;as deste reposit&amp;oacute;rio, ent&amp;atilde;o&amp;nbsp;digite.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git add .
git commit -m "primeiro commit"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora vamos enviar este arquivo para o github com um comando de &lt;code&gt;push&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pronto! Voc&amp;ecirc; deu seus primeiros passos com Git e&amp;nbsp;Gihub!&lt;/p&gt;
&lt;p&gt;Espero que tenham gostado e n&amp;atilde;o esque&amp;ccedil;am de deixar seuas opini&amp;otilde;es e d&amp;uacute;vidas nos&amp;nbsp;coment&amp;aacute;rios!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category><category term="Git"></category><category term="GIthub"></category></entry><entry><title>Tutorial de Git e Github</title><link href="http://programeempython.com.br/tutorial-git-1-en.html" rel="alternate"></link><published>2022-08-07T10:02:00+02:00</published><updated>2022-08-07T10:02:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-07:/tutorial-git-1-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I was writing the next post to the pelican tutorial when I realized that in order to talk about github pages, it&amp;rsquo;s important to first talk about git and github to make sure we&amp;rsquo;re all on the same page later&amp;nbsp;on.&lt;/p&gt;
&lt;p&gt;So what is &lt;span class="caps"&gt;GIT&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Git is …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I was writing the next post to the pelican tutorial when I realized that in order to talk about github pages, it&amp;rsquo;s important to first talk about git and github to make sure we&amp;rsquo;re all on the same page later&amp;nbsp;on.&lt;/p&gt;
&lt;p&gt;So what is &lt;span class="caps"&gt;GIT&lt;/span&gt;?&lt;/p&gt;
&lt;p&gt;Git is a code version management system, that means, it is used to control code changes and is especially useful when we work in collaboration, either in a centralized team or in a distributed way as with open source projects, for&amp;nbsp;example.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll leave here the official page where you can see how to &lt;a href="https://git-scm.com/book/pt-br/v2/Come%C3%A7ando-Instalando-o-Git"&gt;install &lt;span class="caps"&gt;GIT&lt;/span&gt;&lt;/a&gt;. If you use Windows, I recommend using &lt;code&gt;Git Bash&lt;/code&gt;, which is part of the official package, to interact with &lt;span class="caps"&gt;GIT&lt;/span&gt;&amp;nbsp;repositories.&lt;/p&gt;
&lt;p&gt;Since you now have git installed on your computer, let&amp;rsquo;s configure your&amp;nbsp;github.&lt;/p&gt;
&lt;p&gt;Create your account on &lt;a href="https://github.com"&gt;github&lt;/a&gt; if you still don&amp;rsquo;t have&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;On your computer open the terminal where you use git. Here we will generate an &lt;span class="caps"&gt;SSH&lt;/span&gt; key to authenticate to github securely. Enter the&amp;nbsp;command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ssh-keygen
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can just use the default options. They are not the safest but I believe they are good enough to start using it. If you provide a password for your &lt;span class="caps"&gt;SSH&lt;/span&gt; key, you will have to use it whenever you use github access on the terminal, for&amp;nbsp;example.&lt;/p&gt;
&lt;p&gt;After running this command, you will have created a couple of files in the &lt;code&gt;.ssh&lt;/code&gt; folder in your home folder. These are &lt;code&gt;id_rsa&lt;/code&gt; and &lt;code&gt;id_rsa.pub&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We will need the contents of the &lt;code&gt;id_rsa.pub&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Now, on your gihub page, click on your user icon (top right of the page) and from the options select &lt;code&gt;Settings&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github User Settings" src="/images/githubUserMenu.png"/&gt;&lt;/p&gt;
&lt;p&gt;There, under &lt;code&gt;Access&lt;/code&gt; select &lt;code&gt;SSH and GPG keys&lt;/code&gt;. Click on the &lt;code&gt;New SSH Key&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Add SSH" src="/images/githubAddSSH.png"/&gt;&lt;/p&gt;
&lt;p&gt;Copy the contents of the &lt;code&gt;id_rsa.pub&lt;/code&gt; file and paste it in &lt;code&gt;Key&lt;/code&gt;, Give it some relevant name and&amp;nbsp;save.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github Save SSH" src="/images/githubSaveKey.png"/&gt;&lt;/p&gt;
&lt;p&gt;Now your github is set&amp;nbsp;up.&lt;/p&gt;
&lt;p&gt;Then create a repository on github via the &lt;code&gt;+&lt;/code&gt; button in the upper right corner next to the user&amp;nbsp;menu.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github creates repository" src="/images/githubCriaRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;You will see a page with instructions on how to clone your repository. Select the &lt;span class="caps"&gt;SSH&lt;/span&gt; option and copy the&amp;nbsp;link.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Github clones Repo" src="/images/githubCloneRepo.png"/&gt;&lt;/p&gt;
&lt;p&gt;In the terminal,&amp;nbsp;type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clone&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="nv"&gt;@github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;com&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;repositorui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Where you will replace &lt;code&gt;git@github.com:username/repositorui.git&lt;/code&gt; with the &lt;span class="caps"&gt;URL&lt;/span&gt; you copied from github. It should have this format as well, starting with &lt;code&gt;git@github.com&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Enter the created folder and create a file, it can have any name, like &lt;span class="caps"&gt;README&lt;/span&gt;.md for example and write something in&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;Now you need to tell git that it should save changes in this repository, so&amp;nbsp;type.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git add .
git commit -m "first commit"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now let&amp;rsquo;s push this file to github with a &lt;code&gt;push&lt;/code&gt; command.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Done! You&amp;rsquo;ve taken your first steps with Git and&amp;nbsp;Gihub!&lt;/p&gt;
&lt;p&gt;I hope you liked it and don&amp;rsquo;t forget to leave your opinions and questions in the&amp;nbsp;comments!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category><category term="Git"></category><category term="Github"></category></entry><entry><title>Python 101 - Parte 4 - Estruturas Condicionais em Python, o Retorno</title><link href="http://programeempython.com.br/python-101-parte-4.html" rel="alternate"></link><published>2022-08-02T22:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-02:/python-101-parte-4.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Continuando o artigo sobre Estruturas Condicionais em Python, veremos agora algumas outras fomas de usar a constru&amp;ccedil;&amp;atilde;o &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Muitas vezes, n&amp;atilde;o &amp;eacute; poss&amp;iacute;vel resolver um problema …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Continuando o artigo sobre Estruturas Condicionais em Python, veremos agora algumas outras fomas de usar a constru&amp;ccedil;&amp;atilde;o &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais.html"&gt;Estruturas Condicionais em Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Muitas vezes, n&amp;atilde;o &amp;eacute; poss&amp;iacute;vel resolver um problema computacional simplesmente com um if/else. Ent&amp;atilde;o, usamos v&amp;aacute;rios conjuntos de if/else aninhados (um dentro do&amp;nbsp;outro)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;caminho&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;caminho&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Volte para a posicao inicial"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;caminho&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Siga em frente"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;caminho&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Abaixe a cabeca"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;caminho&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Voc&amp;ecirc; caiu no buraco"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Opcao invalida"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Mas, d&amp;aacute; pra perceber que, se voc&amp;ecirc; tiver uma estrutura muito grade de condi&amp;ccedil;&amp;otilde;es, seu c&amp;oacute;digo vai ficar bem bagun&amp;ccedil;ado&amp;hellip; imagina trinta &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; aninhados dessa forma? N&amp;atilde;o&amp;nbsp;d&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, pra resolver este problema, temos a constru&amp;ccedil;&amp;atilde;o &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;. O &lt;code&gt;elif&lt;/code&gt; faz o papel das sequ&amp;ecirc;ncias de &lt;code&gt;else&lt;/code&gt; que cont&amp;eacute;m &lt;code&gt;if&lt;/code&gt;. Veja como o c&amp;oacute;digo fica muito mais leg&amp;iacute;vel e&amp;nbsp;organizado!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;
&lt;span class="normal"&gt;7&lt;/span&gt;
&lt;span class="normal"&gt;8&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d &amp;eacute; positivo"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d &amp;eacute; negativo"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d &amp;eacute; nulo"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Voc&amp;ecirc; pode ter quantos &lt;code&gt;elif&lt;/code&gt; forem necess&amp;aacute;rios entre o &lt;code&gt;if&lt;/code&gt; e o &lt;code&gt;else&lt;/code&gt;. Veja este&amp;nbsp;exemplo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;opcao&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;opcao&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"O valor escolhido foi 0"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;opcao&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"O valor escolhido foi 1"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;opcao&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"O valor escolhido foi 2"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;opcao&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"O valor escolhido foi 3"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"O valor escolhido n&amp;atilde;o &amp;eacute; v&amp;aacute;lido"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;O c&amp;oacute;digo continua organizado e leg&amp;iacute;vel, ajudando no entendimento do&amp;nbsp;programa!&lt;/p&gt;
&lt;p&gt;Provavelmente, neste ponto, as pessoas que conhecem C, C++, java ou algumas outras linguagens devem estar se perguntando: Mas cad&amp;ecirc; o&amp;nbsp;switch?&lt;/p&gt;
&lt;p&gt;Na realidade, python n&amp;atilde;o tem um switch como temos em outras linguagens, sendo que sua fun&amp;ccedil;&amp;atilde;o &amp;eacute; muito bem cumprida pelas estruturas &amp;lsquo;if&amp;rsquo;/&amp;rsquo;elif&amp;rsquo;/&amp;rsquo;else&amp;rsquo;. Estas estruturas ainda tem vantagens sobre algumas implementa&amp;ccedil;&amp;otilde;es do switch que por exemplo somente fazem compara&amp;ccedil;&amp;otilde;es de inteiros e caracteres&amp;nbsp;&amp;uacute;nicos.&lt;/p&gt;
&lt;p&gt;&amp;Eacute; poss&amp;iacute;vel simular um switch de forma muito eficiente e elegnte no Python, mas isto ficar&amp;aacute; para um pr&amp;oacute;ximo post com conte&amp;uacute;do mais&amp;nbsp;avan&amp;ccedil;ado.&lt;/p&gt;
&lt;p&gt;Vamos ficando por&amp;nbsp;aqui.&lt;/p&gt;
&lt;p&gt;No pr&amp;oacute;ximo t&amp;oacute;pico, falaremos de Estruturas de&amp;nbsp;Repeti&amp;ccedil;&amp;atilde;o!&lt;/p&gt;
&lt;p&gt;&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Part 4 - Conditionals in Python, the Return</title><link href="http://programeempython.com.br/python-101-parte-4-en.html" rel="alternate"></link><published>2022-08-02T22:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-02:/python-101-parte-4-en.html</id><summary type="html">&lt;p&gt;Continuing the article series on Conditional Structures in Python, we will now look at some other ways to use the &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; instructions.&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Code Blocks in&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is often not possible …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Continuing the article series on Conditional Structures in Python, we will now look at some other ways to use the &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; instructions.&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Code Blocks in&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html"&gt;Conditional Structures in Python -&amp;nbsp;1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is often not possible to solve a computational problem simply with an &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;. So we use multiple nested &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; sets (one inside the&amp;nbsp;other)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Go back to the starting position"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Go ahead"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Lower your head"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"You fell in the hole"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Invalid option"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;But, you can see that if you have a very nested structure of conditions, your code will be very messy&amp;hellip; imagine thirty &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; instructions nested like that? It gets&amp;nbsp;crazy!&lt;/p&gt;
&lt;p&gt;So, to solve this problem, we have the &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; construct. The &lt;code&gt;elif&lt;/code&gt; plays the role of the &lt;code&gt;else&lt;/code&gt; sequences that contain an &lt;code&gt;if&lt;/code&gt;. See how the code is much more readable and&amp;nbsp;organized!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;
&lt;span class="normal"&gt;6&lt;/span&gt;
&lt;span class="normal"&gt;7&lt;/span&gt;
&lt;span class="normal"&gt;8&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d is positive"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d is negative"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"d is null"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;You can have as many &lt;code&gt;elif&lt;/code&gt; as needed between &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt;. See this&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"The value chosen was 0"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"The value chosen was 1"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"The value chosen was 2"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"The value chosen was 3"&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"The chosen value is not valid"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;The code remains organized and readable, helping you to understand the&amp;nbsp;code!&lt;/p&gt;
&lt;p&gt;Probably, at this point, people who know C, C++, java or some other languages &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;must be asking themselves: But where&amp;rsquo;s the&amp;nbsp;switch?&lt;/p&gt;
&lt;p&gt;Actually, python doesn&amp;rsquo;t have a switch like we have in other languages, and its function is very well fulfilled by the &amp;lsquo;if&amp;rsquo;/&amp;rsquo;elif&amp;rsquo;/&amp;rsquo;else&amp;rsquo; structures. These structures still have advantages over some switch implementations that for example only do integer and single character&amp;nbsp;comparisons.&lt;/p&gt;
&lt;p&gt;It is possible to simulate a switch very efficiently and elegantly in Python, but that will be left for a next post with more advanced&amp;nbsp;content.&lt;/p&gt;
&lt;p&gt;In the next topic, we&amp;rsquo;ll talk about Repetition&amp;nbsp;Structures!&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t forget to send your questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Parte 3 - Estruturas Condicionais em Python</title><link href="http://programeempython.com.br/python-101-parte-3-condicionais.html" rel="alternate"></link><published>2022-08-01T23:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-01:/python-101-parte-3-condicionais.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Continuando nossa s&amp;eacute;rie introdut&amp;oacute;ria sobre Python, vamos falar um pouco sobre as estruturas&amp;nbsp;condicionais.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As estruturas condicionais s&amp;atilde;o essenciais na programa&amp;ccedil;&amp;atilde;o. Sem elas, os programas seriam chatos, mon&amp;oacute;tonos, e nunca teriam a …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Continuando nossa s&amp;eacute;rie introdut&amp;oacute;ria sobre Python, vamos falar um pouco sobre as estruturas&amp;nbsp;condicionais.&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2.html"&gt;Blocos de C&amp;oacute;digo em&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As estruturas condicionais s&amp;atilde;o essenciais na programa&amp;ccedil;&amp;atilde;o. Sem elas, os programas seriam chatos, mon&amp;oacute;tonos, e nunca teriam a capacidade toda que temos&amp;nbsp;atualmente.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sem estruturas condicionais n&amp;atilde;o haveria jogos&amp;nbsp;eletr&amp;ocirc;nicos!!!!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, vejamos como o Python implementa suas estruturas&amp;nbsp;condicionais.&lt;/p&gt;
&lt;p&gt;A principal estrutura condicional do Python (e mais usada tamb&amp;eacute;m) &amp;eacute; a constru&amp;ccedil;&amp;atilde;o &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; ou sua varia&amp;ccedil;&amp;atilde;o &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;if&lt;/code&gt;, traduzindo do ingl&amp;ecirc;s quer dizer se, e else sen&amp;atilde;o, logo, estas constru&amp;ccedil;&amp;otilde;es nos permitem orientar a execu&amp;ccedil;&amp;atilde;o de um trecho de c&amp;oacute;digo. Se isso, faz aquilo, sen&amp;atilde;o, faz aquilo&amp;nbsp;outro&amp;hellip;&lt;/p&gt;
&lt;p&gt;Veja abaixo um exemplo de utiliza&amp;ccedil;&amp;atilde;o do&amp;nbsp;if/else:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x &amp;eacute; par"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x &amp;eacute; impar"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Este c&amp;oacute;digo analisa o valor da vari&amp;aacute;vel &lt;code&gt;x&lt;/code&gt;. Se &lt;code&gt;x % 2&lt;/code&gt; (o resto da divis&amp;atilde;o de &lt;code&gt;x&lt;/code&gt; por &lt;code&gt;2&lt;/code&gt;) for igual a zero, ent&amp;atilde;o o n&amp;uacute;mero &amp;eacute; par, sen&amp;atilde;o, &amp;eacute; impar. Veremos mais fun&amp;ccedil;&amp;otilde;es matem&amp;aacute;ticas em posts&amp;nbsp;futuros.&lt;/p&gt;
&lt;p&gt;Ao digitar estes comando no terminal, ficaria&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;:
...     &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x &amp;eacute; par&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
... &lt;span class="k"&gt;else&lt;/span&gt;:
...     &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x &amp;eacute; impar&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; 
...
&lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;e&lt;/span&gt; &lt;span class="nv"&gt;impar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Recapitulando o que foi dito no texto sobre blocos de c&amp;oacute;digo em Python, quando temos um bloco identado logo abaixo de um comando terminado em :, temos um bloco que est&amp;aacute; diretamente relacionado a este&amp;nbsp;comando.&lt;/p&gt;
&lt;p&gt;No exemplo, temos o comando &lt;code&gt;if x%2==0:&lt;/code&gt; e logo abaixo o print &lt;code&gt;"x &amp;eacute; par"&lt;/code&gt; identado. Isto quer dizer que o c&amp;oacute;digo identado (&lt;code&gt;print("x &amp;eacute; par")&lt;/code&gt;) somente ser&amp;aacute; executado se o resto da divis&amp;atilde;o de &lt;code&gt;x&lt;/code&gt; por &lt;code&gt;2&lt;/code&gt; for&amp;nbsp;zero.&lt;/p&gt;
&lt;p&gt;Caso este resultado seja diferente de zero, x n&amp;atilde;o &amp;eacute; par, e o interpretador encontra o comando &lt;code&gt;else:&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Logo abaxo deste comando, temos &lt;code&gt;print("x &amp;eacute; impar")&lt;/code&gt; que est&amp;aacute; identado, mostrando ao interpretador que este &amp;eacute; o comando que deve ser executado caso a compara&amp;ccedil;&amp;atilde;o dentro do &lt;code&gt;if&lt;/code&gt; seja&amp;nbsp;falsa.&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o vamos esticar o assunto. Por enquanto paramos por aqui, mas espere que logo teremos a continua&amp;ccedil;&amp;atilde;o pra&amp;nbsp;voc&amp;ecirc;!&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de enviar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category><category term="Condicionais"></category></entry><entry><title>Python 101 - part 3 - Python Conditional Structures</title><link href="http://programeempython.com.br/python-101-parte-3-condicionais-en.html" rel="alternate"></link><published>2022-08-01T23:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-08-01:/python-101-parte-3-condicionais-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Continuing our introductory Python series, let&amp;rsquo;s talk a little about conditional&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Code Blocks in&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Conditional structures are essential in programming. Without them, programs would be boring, monotonous, and would never have been able …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Continuing our introductory Python series, let&amp;rsquo;s talk a little about conditional&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-2-en.html"&gt;Code Blocks in&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Conditional structures are essential in programming. Without them, programs would be boring, monotonous, and would never have been able to do what they do&amp;nbsp;today.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Without conditional structures there would be no video&amp;nbsp;games!!!!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, let&amp;rsquo;s see how Python implements its conditional&amp;nbsp;structures.&lt;/p&gt;
&lt;p&gt;Python&amp;rsquo;s main conditional structure (and most used as well) is the &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; construct or its &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; variation.&lt;/p&gt;
&lt;p&gt;These constructions will guide us through the execution of a code snippet. If this, do that, if not, do that other&amp;nbsp;thing&amp;hellip;&lt;/p&gt;
&lt;p&gt;Below is an example of using &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x is even"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"x is odd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;This code parses the value of the variable &lt;code&gt;x&lt;/code&gt;. If &lt;code&gt;x % 2&lt;/code&gt; (the remainder of dividing &lt;code&gt;x&lt;/code&gt; by &lt;code&gt;2&lt;/code&gt;) is equal to zero, then the number is even, otherwise it is odd. We will see more math functions in future&amp;nbsp;posts.&lt;/p&gt;
&lt;p&gt;When typing these commands in the terminal, it would look like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;:
... &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x is even&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
... &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;no&lt;/span&gt;:
... &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x is odd&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
...
&lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;odd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To recap what was said in the text about blocks of code in Python, when we have a block identified just below a command ending in :, a block that is directly related to this&amp;nbsp;command.&lt;/p&gt;
&lt;p&gt;In the example, we have the command &lt;code&gt;if x%2==0:&lt;/code&gt; and just below the print &lt;code&gt;"x is even"&lt;/code&gt; identified. This means that the code identified (&lt;code&gt;print("x is even")&lt;/code&gt;) will only be executed if the remainder of the division &lt;code&gt;x&lt;/code&gt; by &lt;code&gt;2&lt;/code&gt; is&amp;nbsp;zero.&lt;/p&gt;
&lt;p&gt;If this result is non-zero, x is not even, and the interpreter encounters the command &lt;code&gt;else:&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Below this command, &lt;code&gt;print which is identified as the case which is interpreted which should be executed in comparison within the&lt;/code&gt;false&amp;nbsp;if`).&lt;/p&gt;
&lt;p&gt;We will not cherish the matter. For now we stop here, but hope that soon we will have a sequel for&amp;nbsp;you!&lt;/p&gt;
&lt;p&gt;Feel free to post questions and comments in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;Until the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category><category term="Condicionais"></category></entry><entry><title>Tutorial de Pelican com Github Pages e CircleCI - 1</title><link href="http://programeempython.com.br/tutorial-pelican.html" rel="alternate"></link><published>2022-07-31T22:03:00+02:00</published><updated>2022-07-31T22:03:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-31:/tutorial-pelican.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Como prometido, vamos abordar como criei meu blog com Pelican, Github Pages e CircleCI num tutorial. Como &amp;eacute; bastante conte&amp;uacute;do vamos dividir em partes e aqui veremos uma introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;Recapitulando, Pelican &amp;eacute; um gerador de site est&amp;aacute;tico, ou seja, gera um site est&amp;aacute;tico em &lt;span class="caps"&gt;HTML&lt;/span&gt; baseado em …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Como prometido, vamos abordar como criei meu blog com Pelican, Github Pages e CircleCI num tutorial. Como &amp;eacute; bastante conte&amp;uacute;do vamos dividir em partes e aqui veremos uma introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;Recapitulando, Pelican &amp;eacute; um gerador de site est&amp;aacute;tico, ou seja, gera um site est&amp;aacute;tico em &lt;span class="caps"&gt;HTML&lt;/span&gt; baseado em conte&amp;uacute;dos escritos numa linguagem de Markup, geralmente rich text ou markdown. Pelican gera as postagens usando Jinja2 como biblioteca de template. Assim, se voc&amp;ecirc; tem alguma familiaridade com jinja ou Django, que tem uma biblioteca de templates semelhante, voc&amp;ecirc; n&amp;atilde;o vai ter dificuldades em por exemplo criar ou customizar temas para o&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;Primeiro, para criar um site com Pelican, vamos&amp;nbsp;instal&amp;aacute;-lo.&lt;/p&gt;
&lt;p&gt;Pode ser num ambiente virtual ou diretamente na sua instala&amp;ccedil;&amp;atilde;o padr&amp;atilde;o do python. No terminal,&amp;nbsp;execute:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;pip&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto vai instalar o Pelican com suporte a Markdown, que &amp;eacute; minha linguagem de markup&amp;nbsp;preferida.&lt;/p&gt;
&lt;p&gt;Finalizando sua instala&amp;ccedil;&amp;atilde;o, vamos criar um site&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;Crie uma pasta onde ficar&amp;aacute; seu site, para executarmos comandos l&amp;aacute; de dentro. No Linux, seria algo&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir ~/projetos/meu_blog/ -p
cd ~/projetos/meu_blog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ent&amp;atilde;o, agora vamos executar um comando do Pelican que vai iniciar nosso&amp;nbsp;blog.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican-quickstart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Este script vai te perguntar diversas&amp;nbsp;coisas. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Who&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;language&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;specify&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;prefix&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pagination&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;zone&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;America/Sao_Paulo&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Makefile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;automate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;publishing&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Vamos nos manter no mais simples poss&amp;iacute;vel para este tutorial introdut&amp;oacute;rio, ent&amp;atilde;o&amp;nbsp;responda&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Somente&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;digite&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Teste&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Teste&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Somente&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;digite&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Somente&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;digite&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim, o Pelican vai criar um projeto bastante simplificado que podemos usar para iniciar nosso blog. Num pr&amp;oacute;ximo post, vamos executar novamente este comando para criar realmente o blog que vamos publicar, mas aqui como &amp;eacute; somente para introduzir o Pelican vamos manter a&amp;nbsp;simplicidade.&lt;/p&gt;
&lt;p&gt;Agora vamos criar nosso primeiro post exemplo. Veja que o Pelican criou uma estrutura de arquivos assim na pasta do&amp;nbsp;blog:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content/
pelicanconf.py
publishconf.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dentro da pasta content, crie um arquivo, vamos cham&amp;aacute;-lo de teste.md (Muito criativo :p). Nele insira o seguinte&amp;nbsp;conte&amp;uacute;do&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Teste&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;07&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;08&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Geral&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;Ol&amp;aacute;&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Este&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;eacute;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;meu&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;primeiro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Pelican&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto &amp;eacute; o suficiente para um post com Pelican. T&amp;iacute;tulo, data, categoria e o conte&amp;uacute;do em&amp;nbsp;si.&lt;/p&gt;
&lt;p&gt;Agora vamos rodar um servidor de teste e ver o que nosso&amp;nbsp;blog.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican -r -l
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;O resultado deve ser algo&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AutoReload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Monitoring&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`content`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`theme`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`settings`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Serving&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;at&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;://&lt;/span&gt;&lt;span class="mf"&gt;127.0.0.1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Tap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CTRL&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;Docutils&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;has&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;localization&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'pt'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'en'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;instead&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;                                                                                                                                                                                                                                       &lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;Watched&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;does&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;exist&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jcemelanda&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projetos&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;myblog&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="w"&gt;                                                                                                                                                                                                                     &lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Modified&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="n"&gt;tings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generating&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Processed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;drafts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.06&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Acesse o endere&amp;ccedil;o indicado &lt;code&gt;http://127.0.0.1:8000&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Screenshot Pelican 001" src="/images/pelican-tut-001.png"/&gt;&lt;/p&gt;
&lt;p&gt;Esta deve ser a apar&amp;ecirc;ncia do seu&amp;nbsp;blog.&lt;/p&gt;
&lt;p&gt;Agora abra seu arquivo &lt;code&gt;pelicanconf.py&lt;/code&gt;. Seu conte&amp;uacute;do deve ser aproximadamente&amp;nbsp;este:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;AUTHOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;teste&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;SITENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;TESTE&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="nv"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;TIMEZONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;America/Sao_Paulo&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;

&lt;span class="nv"&gt;DEFAULT_LANG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pt&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;

# &lt;span class="nv"&gt;Feed&lt;/span&gt; &lt;span class="nv"&gt;generation&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;usually&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;desired&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;developing&lt;/span&gt;
&lt;span class="nv"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;TRANSLATION_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;AUTHOR_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;AUTHOR_FEED_RSS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;

# &lt;span class="nv"&gt;Blogroll&lt;/span&gt;
&lt;span class="nv"&gt;LINKS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Pelican&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://getpelican.com/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Python.org&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://www.python.org/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Jinja2&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://palletsprojects.com/p/jinja/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;You can modify those links in your config file&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="ss"&gt;)&lt;/span&gt;

# &lt;span class="nv"&gt;Social&lt;/span&gt; &lt;span class="nv"&gt;widget&lt;/span&gt;
&lt;span class="nv"&gt;SOCIAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;You can add links in your config file&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Another social link&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="ss"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;DEFAULT_PAGINATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;False&lt;/span&gt;

# &lt;span class="nv"&gt;Uncomment&lt;/span&gt; &lt;span class="nv"&gt;following&lt;/span&gt; &lt;span class="nv"&gt;line&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;want&lt;/span&gt; &lt;span class="nv"&gt;document&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;relative&lt;/span&gt; &lt;span class="nv"&gt;URLs&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;developing&lt;/span&gt;
#&lt;span class="nv"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Este arquivo &amp;eacute; bem autoexplicativo. Aqui &amp;eacute; nele que mexemos para a maioria das configura&amp;ccedil;&amp;otilde;es do&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;Finalmente, abra o &lt;code&gt;publishconf.py&lt;/code&gt;. Seu conte&amp;uacute;do deve ser aproximadamente&amp;nbsp;este:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# This file is only used if you use `make publish` or&lt;/span&gt;
&lt;span class="c1"&gt;# explicitly specify it as your config file.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;curdir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pelicanconf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# If your site is available via HTTPS, make sure SITEURL begins with https://&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="n"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/all.atom.xml'&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/&lt;/span&gt;&lt;span class="si"&gt;{slug}&lt;/span&gt;&lt;span class="s1"&gt;.atom.xml'&lt;/span&gt;

&lt;span class="n"&gt;DELETE_OUTPUT_DIRECTORY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;

&lt;span class="c1"&gt;# Following items are often useful when publishing&lt;/span&gt;

&lt;span class="c1"&gt;#DISQUS_SITENAME = ""&lt;/span&gt;
&lt;span class="c1"&gt;#GOOGLE_ANALYTICS = ""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Veja que este arquivo importa de pelicanconf, logo, aqui voc&amp;ecirc; consegue sobrescrever configura&amp;ccedil;&amp;otilde;es, te permitindo ter uma configura&amp;ccedil;&amp;atilde;o para seu ambiente onde escreve os posts e outra para a efetiva publica&amp;ccedil;&amp;atilde;o do&amp;nbsp;site.&lt;/p&gt;
&lt;p&gt;No momento, estas informa&amp;ccedil;&amp;otilde;es s&amp;atilde;o suficientes para prosseguirmos, ent&amp;atilde;o, n&amp;atilde;o perca a pr&amp;oacute;xima parte deste tutorial onde vamos falar sobre Github pages para depois juntarmos as duas coisas&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;Espero que tenham gostado e n&amp;atilde;o esque&amp;ccedil;am de deixar suas opini&amp;otilde;es e d&amp;uacute;vidas nos&amp;nbsp;coment&amp;aacute;rios!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Pelican tutorial with Github Pages and CircleCI - 1</title><link href="http://programeempython.com.br/tutorial-pelican-en.html" rel="alternate"></link><published>2022-07-31T22:03:00+02:00</published><updated>2022-07-31T22:03:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-31:/tutorial-pelican-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;As promised, we&amp;rsquo;ll cover how I created my blog with Pelican, Github Pages and CircleCI in a tutorial. As it is a lot of content, we will divide it into parts and here we will see an introduction to&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;To recap, Pelican is a static site generator …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;As promised, we&amp;rsquo;ll cover how I created my blog with Pelican, Github Pages and CircleCI in a tutorial. As it is a lot of content, we will divide it into parts and here we will see an introduction to&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;To recap, Pelican is a static site generator, that is, it generates a static &lt;span class="caps"&gt;HTML&lt;/span&gt; site based on content written in a Markup language, usually rich text or markdown. Pelican generates the posts using Jinja2 as the template library. So, if you have some familiarity with jinja or Django, which has a similar template library, you won&amp;rsquo;t have any difficulties in, for example, creating or customizing themes for&amp;nbsp;Pelican.&lt;/p&gt;
&lt;p&gt;First, to create a website with Pelican, let&amp;rsquo;s install&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;It can be in a virtual environment or directly in your default python installation. In the terminal,&amp;nbsp;run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;pip&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pelican&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will install Pelican with Markdown support, which is my favorite markup&amp;nbsp;language.&lt;/p&gt;
&lt;p&gt;Finishing your installation, let&amp;rsquo;s create a Pelican&amp;nbsp;website.&lt;/p&gt;
&lt;p&gt;Create a folder where your site will be, so we can run commands from there. On Linux it would be something like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir ~/projects/my_blog/ -p
cd ~/projects/my_blog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So now let&amp;rsquo;s run a Pelican command that will start our&amp;nbsp;blog.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican-quickstart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This script will ask you several&amp;nbsp;questions.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;create&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Who&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;will&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;language&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;en&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;specify&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;prefix&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;enable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pagination&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;What&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;zone&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;America/New_York&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;you&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;want&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Makefile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;automate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;generation&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;publishing&lt;/span&gt;&lt;span class="vm"&gt;?&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let&amp;rsquo;s keep it as simple as possible for this introductory tutorial, so&amp;nbsp;answer&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Just&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Test&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Test&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Just&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Just&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`Enter`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So Pelican will create a very simplified project that we can use to start our blog. In a next post, we&amp;rsquo;ll run this command again to actually create the blog we&amp;rsquo;re going to publish, but here, as it&amp;rsquo;s just to introduce Pelican, let&amp;rsquo;s keep it&amp;nbsp;simple.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s create our first example post. See that Pelican created a file structure like this in the blog&amp;nbsp;folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;content /
pelicanconf.py
publishconf.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Inside the content folder, create a file, let&amp;rsquo;s call it teste.md (Very creative :p). In it insert the following&amp;nbsp;content&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Test&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;07&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;08&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Category&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;General&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="n"&gt;Hi&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Pelican&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is enough for a post with Pelican. Title, date, category and the content&amp;nbsp;itself.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s run a test server and see what our blog looks&amp;nbsp;like.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pelican -r -l
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result should be something like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;AutoReload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Monitoring&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`content`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`theme`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n n-Quoted"&gt;`settings`&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Serving&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;at&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;://&lt;/span&gt;&lt;span class="mf"&gt;127.0.0.1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Tap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CTRL&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;stop&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="err"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Docutils&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;has&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;localization&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'pt'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'en'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;instead&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;WARNING&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Watched&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;path&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;does&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;exist&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;jcemelanda&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;projects&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;myblog&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Modified&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="n"&gt;tings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;generating&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;Done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Processed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;drafts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;draft&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.06&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Access the indicated address &lt;code&gt;http://127.0.0.1:8000&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Screenshot Pelican 001" src="/images/pelican-tut-001-en.png"/&gt;&lt;/p&gt;
&lt;p&gt;This should be what your blog looks&amp;nbsp;like.&lt;/p&gt;
&lt;p&gt;Now open your &lt;code&gt;pelicanconf.py&lt;/code&gt; file. Your content should look like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;AUTHOR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;test&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;SITENAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;TEST&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;

&lt;span class="nv"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;
&lt;span class="nv"&gt;TIMEZONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;America/New_York&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;

&lt;span class="nv"&gt;DEFAULT_LANG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;en&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;

# &lt;span class="nv"&gt;Feed&lt;/span&gt; &lt;span class="nv"&gt;generation&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;usually&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;desired&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;developing&lt;/span&gt;
&lt;span class="nv"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;TRANSLATION_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;AUTHOR_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;
&lt;span class="nv"&gt;AUTHOR_FEED_RSS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;None&lt;/span&gt;

# &lt;span class="nv"&gt;blogroll&lt;/span&gt;
&lt;span class="nv"&gt;LINKS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Pelican&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://getpelican.com/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Python.org&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://www.python.org/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Jinja2&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://palletsprojects.com/p/jinja/&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;You can modify those links in your config file&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="ss"&gt;)&lt;/span&gt;

# &lt;span class="nv"&gt;Social&lt;/span&gt; &lt;span class="nv"&gt;widget&lt;/span&gt;
&lt;span class="nv"&gt;SOCIAL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;You can add links in your config file&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,
        &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Another social link&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;, &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;,&lt;span class="ss"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;DEFAULT_PAGINATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;False&lt;/span&gt;

# &lt;span class="nv"&gt;Uncomment&lt;/span&gt; &lt;span class="nv"&gt;following&lt;/span&gt; &lt;span class="nv"&gt;line&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;you&lt;/span&gt; &lt;span class="nv"&gt;want&lt;/span&gt; &lt;span class="nv"&gt;document&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;relative&lt;/span&gt; &lt;span class="nv"&gt;URLs&lt;/span&gt; &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;developing&lt;/span&gt;
#&lt;span class="nv"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This file is very self explanatory. This is where we tweak most of the Pelican&amp;nbsp;settings.&lt;/p&gt;
&lt;p&gt;Finally, open &lt;code&gt;publishconf.py&lt;/code&gt;. Your content should look like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# This file is only used if you use `make publish` or&lt;/span&gt;
&lt;span class="c1"&gt;# explicitly specify it as your config file.&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;them&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;curdir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pelicanconf&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# If your site is available via HTTPS, make sure SITEURL begins with https://&lt;/span&gt;
&lt;span class="n"&gt;SITEURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="n"&gt;RELATIVE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;FEED_ALL_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/all.atom.xml'&lt;/span&gt;
&lt;span class="n"&gt;CATEGORY_FEED_ATOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'feeds/&lt;/span&gt;&lt;span class="si"&gt;{slug}&lt;/span&gt;&lt;span class="s1"&gt;.atom.xml'&lt;/span&gt;

&lt;span class="n"&gt;DELETE_OUTPUT_DIRECTORY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;

&lt;span class="c1"&gt;# Following items are often useful when publishing&lt;/span&gt;

&lt;span class="c1"&gt;#DISQUS_SITENAME = ""&lt;/span&gt;
&lt;span class="c1"&gt;#GOOGLE_ANALYTICS = ""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;See that this file imports from pelicanconf, so here you can overwrite configurations, allowing you to have a configuration for your environment where you write posts and another for the effective publication of the&amp;nbsp;site.&lt;/p&gt;
&lt;p&gt;For the moment, this information is enough to go on, so don&amp;rsquo;t miss the next part of this tutorial where we&amp;rsquo;ll talk about Github pages and then put the two together&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;I hope you liked it and don&amp;rsquo;t forget to leave your opinions and questions in the&amp;nbsp;comments!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Pelican"></category><category term="Github Pages"></category><category term="CircleCI"></category></entry><entry><title>Python 101 - Segunda Parte</title><link href="http://programeempython.com.br/python-101-parte-2.html" rel="alternate"></link><published>2022-07-29T12:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-29:/python-101-parte-2.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Agora que j&amp;aacute; temos o Python instalado e j&amp;aacute; conhecemos a sua interface interativa, vamos aprender um pouco sobre os comandos mais b&amp;aacute;sicos da&amp;nbsp;linguagem!&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Como visto, no shell Python, temos dois&amp;nbsp;cursores:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ao fazermos um if …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Agora que j&amp;aacute; temos o Python instalado e j&amp;aacute; conhecemos a sua interface interativa, vamos aprender um pouco sobre os comandos mais b&amp;aacute;sicos da&amp;nbsp;linguagem!&lt;/p&gt;
&lt;p&gt;Caso n&amp;atilde;o tenha visto os tutoriais anteriores, j&amp;aacute;&amp;nbsp;temos:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1.html"&gt;Introdu&amp;ccedil;&amp;atilde;o ao&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Como visto, no shell Python, temos dois&amp;nbsp;cursores:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ao fazermos um if, estrutura condicional que ser&amp;aacute; explicada em mais detalhes num pr&amp;oacute;ximo post, temos o seguinte no&amp;nbsp;console:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;:
...     &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x &amp;eacute; menor que 1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
... 
&lt;span class="nv"&gt;x&lt;/span&gt; &amp;eacute; &lt;span class="nv"&gt;menor&lt;/span&gt; &lt;span class="nv"&gt;que&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora, a explica&amp;ccedil;&amp;atilde;o&amp;nbsp;=]&lt;/p&gt;
&lt;p&gt;Na primeira linha, dizemos que a vari&amp;aacute;vel x cont&amp;eacute;m o valor 0;
Em seguida, comparamos o valor contido em x com 1. Ao terminarmos um comando com : o interpretador entende que este &amp;eacute; um comando que n&amp;atilde;o acabou no final daquela linha, e que &amp;eacute; composto por mais comandos, ent&amp;atilde;o surge o cursor secund&amp;aacute;rio &lt;code&gt;...&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o, muitos programadores habituados com outras linguagens devem se perguntar onde est&amp;atilde;o as chaves pra determinar o&amp;nbsp;bloco.&lt;/p&gt;
&lt;p&gt;No Python, os blocos s&amp;atilde;o determinados pela identa&amp;ccedil;&amp;atilde;o (ou edenta&amp;ccedil;&amp;atilde;o, ou endenta&amp;ccedil;&amp;atilde;o&amp;hellip; j&amp;aacute; vi v&amp;aacute;rias formas da&amp;nbsp;palavra).&lt;/p&gt;
&lt;p&gt;As linhas que est&amp;atilde;o dentro do if, ou seja o que deve ser executado caso a compara&amp;ccedil;&amp;atilde;o seja verdadeira deve estar&amp;nbsp;identado.&lt;/p&gt;
&lt;p&gt;Em geral &amp;eacute; uma conven&amp;ccedil;&amp;atilde;o, no Python, usarmos 4 espa&amp;ccedil;os para a&amp;nbsp;identa&amp;ccedil;&amp;atilde;o.&lt;/p&gt;
&lt;p&gt;O &lt;code&gt;print("x &amp;eacute; menor que 1")&lt;/code&gt; &amp;eacute; o comando que deve ser executado se a compara&amp;ccedil;&amp;atilde;o &lt;code&gt;x &amp;lt; 1&lt;/code&gt; for verdadeira. Assim, esta linha est&amp;aacute; identada, e o interpretador sabe que s&amp;oacute; deve execut&amp;aacute;-la caso &lt;em&gt;x&lt;/em&gt; seja menor que &lt;em&gt;1&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Quando voc&amp;ecirc; d&amp;aacute; um &lt;code&gt;ENTER&lt;/code&gt; no final desta linha, o interpretador te mostra novamente o cursor secund&amp;aacute;rio, pois um &lt;code&gt;if&lt;/code&gt; pode ter v&amp;aacute;rios comandos ali dentro. Como veremos mais adiante a execu&amp;ccedil;&amp;atilde;o de um programa todo pode estar dentro de um &lt;strong&gt;if&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Assim, s&amp;oacute; depois de um segundo &lt;code&gt;ENTER&lt;/code&gt; &amp;eacute; que o interpretador executa o comando e mostra o&amp;nbsp;resultado.&lt;/p&gt;
&lt;p&gt;Ent&amp;atilde;o,&amp;nbsp;recapitulando:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Blocos em Python s&amp;atilde;o definidos pela&amp;nbsp;identa&amp;ccedil;&amp;atilde;o&lt;/li&gt;
&lt;li&gt;A identa&amp;ccedil;&amp;atilde;o deve seguir um padr&amp;atilde;o, preferencialmente em todos os&amp;nbsp;programas&lt;/li&gt;
&lt;li&gt;&amp;Eacute; conven&amp;ccedil;&amp;atilde;o usar 4 espa&amp;ccedil;os para&amp;nbsp;identa&amp;ccedil;&amp;atilde;o&lt;/li&gt;
&lt;li&gt;No interpretador, blocos identados s&amp;atilde;o precedidos do cursos secund&amp;aacute;rio&amp;nbsp;&amp;hellip;&lt;/li&gt;
&lt;li&gt;Um bloco indica um trecho de c&amp;oacute;digo que est&amp;aacute; dentro de outro&amp;nbsp;comando&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Por enquanto &amp;eacute;&amp;nbsp;s&amp;oacute;!&lt;/p&gt;
&lt;p&gt;No pr&amp;oacute;ximo post aproveitamos a deixa, e falamos sobre estruturas condicionais em&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixe de deixar d&amp;uacute;vidas e opini&amp;otilde;es nos coment&amp;aacute;rios&amp;nbsp;abaixo!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Segunda Parte</title><link href="http://programeempython.com.br/python-101-parte-2-en.html" rel="alternate"></link><published>2022-07-29T12:06:00+02:00</published><updated>2022-08-07T13:25:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-29:/python-101-parte-2-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Now that we have Python installed and we already know its interactive interface, let&amp;rsquo;s learn a little about the most basic commands of the&amp;nbsp;language!&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As seen, in the Python shell we have two&amp;nbsp;cursors …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Now that we have Python installed and we already know its interactive interface, let&amp;rsquo;s learn a little about the most basic commands of the&amp;nbsp;language!&lt;/p&gt;
&lt;p&gt;I you haven&amp;rsquo;t seen our previous tutorials, check&amp;nbsp;here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://programeempython.com.br/python-101-parte-1-en.html"&gt;Introdution to&amp;nbsp;Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As seen, in the Python shell we have two&amp;nbsp;cursors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When we make an if, conditional structure that will be explained in more detail in a next post, we have the following in the&amp;nbsp;console:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;:
...     &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;x is less than 1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
...
&lt;span class="nv"&gt;x&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;less&lt;/span&gt; &lt;span class="nv"&gt;than&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the explanation&amp;nbsp;=]&lt;/p&gt;
&lt;p&gt;In the first line, we say that the variable &lt;em&gt;x&lt;/em&gt; contains the value &lt;em&gt;0&lt;/em&gt;;
Next, we compare the value contained in &lt;em&gt;x&lt;/em&gt; with &lt;em&gt;1&lt;/em&gt;. When we end a command with &lt;strong&gt;:&lt;/strong&gt; the interpreter understands that this is a command that did not end at the end of that line, and that it is composed of more commands, so the secondary cursor &lt;code&gt;...&lt;/code&gt; gets in the&amp;nbsp;game.&lt;/p&gt;
&lt;p&gt;So, many programmers used to other languages &amp;ZeroWidthSpace;&amp;ZeroWidthSpace;must ask themselves where are the curly braces to determine the&amp;nbsp;block.&lt;/p&gt;
&lt;p&gt;In Python, blocks are determined by&amp;nbsp;indentation.&lt;/p&gt;
&lt;p&gt;The lines that are inside the &lt;em&gt;if&lt;/em&gt;, ie what must be executed if the comparison is true must be&amp;nbsp;indented.&lt;/p&gt;
&lt;p&gt;It is generally a convention, in Python, to use 4 spaces for the&amp;nbsp;indentation.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;print("x is less than 1")&lt;/code&gt; is the command that should be executed if the comparison &lt;code&gt;x &amp;lt; 1&lt;/code&gt; is true. Thus, this line is indented, and the interpreter knows that it should only execute it if &lt;em&gt;x&lt;/em&gt; is less than &lt;em&gt;1&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;When you press &lt;code&gt;ENTER&lt;/code&gt; at the end of this line, the interpreter shows you the secondary cursor again, because an &lt;code&gt;if&lt;/code&gt; can have several commands inside. As we will see later, the execution of an entire program can be inside an &lt;strong&gt;if&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Thus, only after a second &lt;code&gt;ENTER&lt;/code&gt; does the interpreter execute the command and display the&amp;nbsp;result.&lt;/p&gt;
&lt;p&gt;So, let&amp;rsquo;s&amp;nbsp;recap:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Blocks in Python are defined by&amp;nbsp;indentation&lt;/li&gt;
&lt;li&gt;The indentation must follow a pattern, preferably in all&amp;nbsp;programs&lt;/li&gt;
&lt;li&gt;It is convention to use 4 spaces for&amp;nbsp;indentation&lt;/li&gt;
&lt;li&gt;In the interpreter, indented blocks are preceded by the secondary cursor &lt;code&gt;...&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;A block indicates a snippet of code that is inside another&amp;nbsp;command&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s all for&amp;nbsp;now!&lt;/p&gt;
&lt;p&gt;In the next Python 101 post we take the hint, and talk about conditional structures in&amp;nbsp;Python!&lt;/p&gt;
&lt;p&gt;Be sure to leave your questions and opinions in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - Primeira Parte</title><link href="http://programeempython.com.br/python-101-parte-1.html" rel="alternate"></link><published>2022-07-29T01:06:00+02:00</published><updated>2022-07-31T01:44:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-29:/python-101-parte-1.html</id><summary type="html">&lt;p&gt;Bom, um blog com o nome Programe em Python n&amp;atilde;o pode ficar sem um tutorial b&amp;aacute;sico de Python,&amp;nbsp;n&amp;eacute;?&lt;/p&gt;
&lt;p&gt;Antes de mais nada, se voc&amp;ecirc; usa Linux ou MacOS voc&amp;ecirc; provavelmente j&amp;aacute; tem o Python ent&amp;atilde;o voc&amp;ecirc; est&amp;aacute; com&amp;nbsp;sorte.&lt;/p&gt;
&lt;p&gt;No windows, v&amp;aacute; &amp;agrave; &lt;a href="https://www.python.org/downloads/"&gt;p&amp;aacute;gina de downloads do Python&lt;/a&gt; e …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Bom, um blog com o nome Programe em Python n&amp;atilde;o pode ficar sem um tutorial b&amp;aacute;sico de Python,&amp;nbsp;n&amp;eacute;?&lt;/p&gt;
&lt;p&gt;Antes de mais nada, se voc&amp;ecirc; usa Linux ou MacOS voc&amp;ecirc; provavelmente j&amp;aacute; tem o Python ent&amp;atilde;o voc&amp;ecirc; est&amp;aacute; com&amp;nbsp;sorte.&lt;/p&gt;
&lt;p&gt;No windows, v&amp;aacute; &amp;agrave; &lt;a href="https://www.python.org/downloads/"&gt;p&amp;aacute;gina de downloads do Python&lt;/a&gt; e baixe dali a vers&amp;atilde;o mais&amp;nbsp;recente.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Download Python" src="/images/download-python.png"/&gt;&lt;/p&gt;
&lt;p&gt;Quando terminar o download, execute o instalador e siga as instru&amp;ccedil;&amp;otilde;es de&amp;nbsp;instala&amp;ccedil;&amp;atilde;o.&lt;/p&gt;
&lt;p&gt;Lembre-se de marcar a op&amp;ccedil;&amp;atilde;o para inserir Python nos caminhos do sistema (&lt;em&gt;Add Python to &lt;span class="caps"&gt;PATH&lt;/span&gt;&lt;/em&gt;), pois isto vai facilitar muito a sua&amp;nbsp;vida.&lt;/p&gt;
&lt;p&gt;Quando o Python estiver finalmente instalado, numa janela de linha de comando, (&lt;span class="caps"&gt;CMD&lt;/span&gt; ou powershell no Windows) digite Python e voc&amp;ecirc; deve ver algo semelhante a&amp;nbsp;isto.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Terminal Python" src="/images/python-terminal.png"/&gt;&lt;/p&gt;
&lt;p&gt;Veja que na primeira linha voc&amp;ecirc; consegue ver qual a vers&amp;atilde;o do Python, e na &amp;uacute;ltima linha h&amp;aacute; um prompt esperando pelos seus&amp;nbsp;comandos. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Este prompt ser&amp;aacute; usado neste blog sempre para denotar que devemos escrever c&amp;oacute;digo no console do&amp;nbsp;Python.&lt;/p&gt;
&lt;p&gt;Fa&amp;ccedil;a um teste. Digite, seguido de &lt;code&gt;ENTER&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print('Ol&amp;aacute; Mundo!')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;O resultado deve ser algo&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print('Ol&amp;aacute; Mundo!')
Ol&amp;aacute; Mundo!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isto significa que o console do Python j&amp;aacute; te retorna as respostas para os comando logo em seguida de voc&amp;ecirc; execut&amp;aacute;-los. Veja por&amp;nbsp;exemplo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 23*256/98+3
63.08163265306123
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finalmente, quando formos executar c&amp;oacute;digos com blocos, como &lt;code&gt;if&lt;/code&gt; por exemplo, ser&amp;aacute;&amp;nbsp;assim:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;True&lt;/span&gt;:
...     &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;Eacute; verdade!&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
...
&amp;Eacute; &lt;span class="nv"&gt;verdade&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim, note que os 3 pontos &lt;code&gt;...&lt;/code&gt; s&amp;atilde;o indicadores de bloco de c&amp;oacute;digo no terminal do Python, ou seja, indicam que um comando iniciado acima ainda n&amp;atilde;o foi terminado. Desta forma, precisamos inserir uma linha em branco para o Python perceber que finalizamos aquele comando e ele pode ent&amp;atilde;o&amp;nbsp;execut&amp;aacute;-lo.&lt;/p&gt;
&lt;p&gt;Acho que este &amp;eacute; um bom momento para finalizarmos esta primeira parte do tutorial&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;N&amp;atilde;o deixem de &lt;strong&gt;comentar&lt;/strong&gt; abaixo com sua opini&amp;atilde;o e&amp;nbsp;d&amp;uacute;vidas!&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Python 101 - First Part</title><link href="http://programeempython.com.br/python-101-parte-1-en.html" rel="alternate"></link><published>2022-07-29T01:06:00+02:00</published><updated>2022-07-29T01:06:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-29:/python-101-parte-1-en.html</id><summary type="html">&lt;p&gt;Well, a blog with the name Programe em Python can&amp;rsquo;e exist without a basic Python Tutorial,&amp;nbsp;right?&lt;/p&gt;
&lt;p&gt;First things first, if you are using Linux or &lt;span class="caps"&gt;OSX&lt;/span&gt; you most probably already have Python installed, so you are a lucky person&amp;nbsp;;)&lt;/p&gt;
&lt;p&gt;On windows, go to the &lt;a href="https://www.python.org/downloads/"&gt;Python downloads page&lt;/a&gt; and …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Well, a blog with the name Programe em Python can&amp;rsquo;e exist without a basic Python Tutorial,&amp;nbsp;right?&lt;/p&gt;
&lt;p&gt;First things first, if you are using Linux or &lt;span class="caps"&gt;OSX&lt;/span&gt; you most probably already have Python installed, so you are a lucky person&amp;nbsp;;)&lt;/p&gt;
&lt;p&gt;On windows, go to the &lt;a href="https://www.python.org/downloads/"&gt;Python downloads page&lt;/a&gt; and download the most recent version from&amp;nbsp;there.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Download Python" src="/images/download-python.png"/&gt;&lt;/p&gt;
&lt;p&gt;When the download is complete, run the installer and follow the installation&amp;nbsp;instructions.&lt;/p&gt;
&lt;p&gt;Remember to check the option to insert Python in the system paths (&lt;em&gt;Add Python to &lt;span class="caps"&gt;PATH&lt;/span&gt;&lt;/em&gt;), as this will make your life a lot&amp;nbsp;easier.&lt;/p&gt;
&lt;p&gt;When Python is finally installed, in a command line window (&lt;span class="caps"&gt;CMD&lt;/span&gt; or powershell on Windows) type Python and you should see something similar to&amp;nbsp;this.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Python Terminal" src="/images/python-terminal.png"/&gt;&lt;/p&gt;
&lt;p&gt;See that on the first line you can see the version of Python, and on the last line there is a prompt waiting for your&amp;nbsp;commands.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This prompt will be used throughout this blog to denote that we must write code in the Python console.
Try it. Type, followed by &lt;code&gt;ENTER&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print('Hello World!')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result should be something like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; print('Hello World!')
Hello World!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This means that the Python console already returns the answers to the commands right after you execute them. See for&amp;nbsp;example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; 23*256/98+3
63.08163265306123
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, when we run code with blocks, like &lt;code&gt;if&lt;/code&gt; for example, it will look like&amp;nbsp;this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;True&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:
... &lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;It&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;s&lt;/span&gt; &lt;span class="nv"&gt;true&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;
...
&lt;span class="nv"&gt;It&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;s true!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So, note that the 3 dots &lt;code&gt;...&lt;/code&gt; are code block indicators in the Python terminal, that means they indicate that a command started above has not yet been finished. This way, we need to insert a blank line for Python to realize that we have finished that command and it can then execute&amp;nbsp;it.&lt;/p&gt;
&lt;p&gt;I think this is a good time to finish this first part of the tutorial&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t forget to &lt;strong&gt;comment&lt;/strong&gt; below with your opinion and&amp;nbsp;questions!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Tutoriais"></category><category term="Tutorial"></category><category term="Python 101"></category></entry><entry><title>Porque Pelican</title><link href="http://programeempython.com.br/porque-pelican.html" rel="alternate"></link><published>2022-07-25T22:03:00+02:00</published><updated>2022-07-28T01:52:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-25:/porque-pelican.html</id><summary type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Eu andei avaliando se e como eu deveria retomar o blog, e depois de muitas ideias, aqui estamos, e acho que nada como come&amp;ccedil;ar falando um pouco sobre o processo de decis&amp;atilde;o para escolher fazer o blog em Pelican hospedado no Github Pages ao inv&amp;eacute;s de qualquer outra&amp;nbsp;plataforma …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ol&amp;aacute;!&lt;/p&gt;
&lt;p&gt;Eu andei avaliando se e como eu deveria retomar o blog, e depois de muitas ideias, aqui estamos, e acho que nada como come&amp;ccedil;ar falando um pouco sobre o processo de decis&amp;atilde;o para escolher fazer o blog em Pelican hospedado no Github Pages ao inv&amp;eacute;s de qualquer outra&amp;nbsp;plataforma.&lt;/p&gt;
&lt;p&gt;Para isto acho que podemos come&amp;ccedil;ar com um pequeno hist&amp;oacute;rico do&amp;nbsp;blog.&lt;/p&gt;
&lt;p&gt;Minha primeira vers&amp;atilde;o do Programe em Python foi no Blogger. Era bastante f&amp;aacute;cil e pr&amp;aacute;tico de in&amp;iacute;cio, por&amp;eacute;m, para customizar as p&amp;aacute;ginas era um tanto trabalhoso devido &amp;agrave;s especificidades dos templates &lt;span class="caps"&gt;HTML&lt;/span&gt; do&amp;nbsp;Blogger.&lt;/p&gt;
&lt;p&gt;Depois, migrei para uma solu&amp;ccedil;&amp;atilde;o django rodando no openshift da redhat. Eu adorava. 100% customiz&amp;aacute;vel, meus textos saiam bem como eu queria, mas depois de um tempo, o openshift teve mudan&amp;ccedil;as pras quais eu demorei pra me atentar e tive que fazer um backup super corrido dos textos e infelizmente n&amp;atilde;o consegui mais continuar com o&amp;nbsp;blog.&lt;/p&gt;
&lt;p&gt;Um tempo depois eu descobri github pages e pelican e fiz uma tentativa inicial, mas n&amp;atilde;o estava num bom momento e o projeto mais uma vez n&amp;atilde;o foi pra&amp;nbsp;frente.&lt;/p&gt;
&lt;p&gt;Agora, quando decidi retomar o blog tive que escolher entre continuar usando github pages e pelican ou procurar uma nova&amp;nbsp;plataforma.&lt;/p&gt;
&lt;p&gt;Minha escolha teve alguns pontos&amp;nbsp;decisivos.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;O blog &amp;eacute; um site est&amp;aacute;tico e dificilmente vou precisar de muito mais do que um site est&amp;aacute;tico pode me oferecer, dado que o Pelican simplifica muito a postagem dos textos e acrescentar as&amp;nbsp;p&amp;aacute;ginas.&lt;/li&gt;
&lt;li&gt;Git &amp;eacute; um sistema que eu uso diariamente e que eu sempre recomendo, al&amp;eacute;m de permitir versionamento dos texto, o que pode ser bastante &amp;uacute;til, eu posso escrever de basicamente qualquer lugar e enviar facilmente para o&amp;nbsp;github.&lt;/li&gt;
&lt;li&gt;Pelican &amp;eacute; um gerador de sites est&amp;aacute;ticos, que me permite facilmente acrescentar novos posts ao blog, escrevendo com&amp;nbsp;Markdown&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alguns pontos precisei levar em considera&amp;ccedil;&amp;atilde;o s&amp;atilde;o que o Pelican n&amp;atilde;o tem um suporte nativo no Github Pages como tem o Jekyll por exemplo, e para ter busca e outras features, precisei de alguns plugins do pelican. Isto aumenta um pouco as complexidades, por&amp;eacute;m n&amp;atilde;o o suficiente para me&amp;nbsp;desanimar.&lt;/p&gt;
&lt;p&gt;Algo que eu fiz tamb&amp;eacute;m foi implementar um workflow no CircleCI para publicar a postagem quando eu fizer um commit na branch do blog, assim, a publica&amp;ccedil;&amp;atilde;o que dependeria de eu rodar alguns comandos do pelican fica&amp;nbsp;automatizada.&lt;/p&gt;
&lt;p&gt;Uma pergunta que pode ficar &amp;eacute;, por que usei Pelican no lugar de Jekyll ou Hugo por&amp;nbsp;exemplo?&lt;/p&gt;
&lt;p&gt;Minha ideia neste sentido foi bem simples. Eu queria um gerador de site est&amp;aacute;tico feito em Python. Assim, se eu eu sentir que preciso de algo ou que tem um bug eu posso trabalhar na mudan&amp;ccedil;a&amp;nbsp;facilmente.&lt;/p&gt;
&lt;p&gt;Tamb&amp;eacute;m, Pelican usa Jinja2 para os templates, e esta biblioteca eu j&amp;aacute; usei diversas vezes, al&amp;eacute;m de ser parecida com a biblioteca de templates do&amp;nbsp;Django.&lt;/p&gt;
&lt;p&gt;Assim, aqui estamos. Um blog usando Pelican para gerar o site, o host sendo o sistema de pages do github, e com CircleCI automatizando as publica&amp;ccedil;&amp;otilde;es quando eu envio os&amp;nbsp;posts.&lt;/p&gt;
&lt;p&gt;Espero que tenham gostado. Quer saber mais sobre como funciona o Pelican, ou como criar seu pr&amp;oacute;prio blog usando esta&amp;nbsp;stack?&lt;/p&gt;
&lt;p&gt;Deixe seu&amp;nbsp;coment&amp;aacute;rio!&lt;/p&gt;
&lt;p&gt;Te vejo no pr&amp;oacute;ximo&amp;nbsp;psot!&lt;/p&gt;</content><category term="Blogging"></category><category term="Geral"></category><category term="Blogging"></category></entry><entry><title>Porque Pelican</title><link href="http://programeempython.com.br/porque-pelican-en.html" rel="alternate"></link><published>2022-07-25T22:03:00+02:00</published><updated>2022-07-28T01:52:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-25:/porque-pelican-en.html</id><summary type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been thinking about how and if I should restart blogging, and after a long brainstorm, here we are, and I think nothing could be better here than to talk a little about the thinking process of my decision to use Pelican hosted on Github Pages instead of …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve been thinking about how and if I should restart blogging, and after a long brainstorm, here we are, and I think nothing could be better here than to talk a little about the thinking process of my decision to use Pelican hosted on Github Pages instead of any other&amp;nbsp;platform.&lt;/p&gt;
&lt;p&gt;So, I think we can start with a little timeline of my blog&amp;rsquo;s&amp;nbsp;history.&lt;/p&gt;
&lt;p&gt;My first version of Programe em Python was hosted on Blogger. It was quite easy and practical at first, but, it wasn&amp;rsquo;t that easy to customize the pages because it has some very specific things on it&amp;rsquo;s &lt;span class="caps"&gt;HTML&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;After that I migrated to a django solution running on RedHat&amp;rsquo;s Openshift. I used to love it. It was 100% customizable, my texts wen&amp;rsquo;t through exectly as I wanted them to be, but after a while, opeshift changed it&amp;rsquo;s rules and I took to long to notice as I wasn&amp;rsquo;t on the best of my moments at that time. In the end I had to make a backup in a hurry, ando unfortunately I couldnt go on with the blog after&amp;nbsp;that.&lt;/p&gt;
&lt;p&gt;Some time later I found out about Github Pages and pelican, and I took my changes, but it wasn&amp;rsquo;t still a good moment for me and the project once again&amp;nbsp;stalled.&lt;/p&gt;
&lt;p&gt;Now, when I decided to blog again, I had to choose between going on with Github Pages + Pelican or to look for something else that would fit me as I&amp;nbsp;wanted.&lt;/p&gt;
&lt;p&gt;I had some decisive points to&amp;nbsp;consider.vos.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The blog is mostly a static content website and it would hardly ever need much more than a static site given that with Pelican it&amp;rsquo;s quite easy to add new articles and&amp;nbsp;pages.&lt;/li&gt;
&lt;li&gt;Git is something I use daily and I always recommend, besides that it would allow me to blog from basically anywhere. Also, I would have my posts in a version control system, and that can come in handy&amp;nbsp;sometimes.&lt;/li&gt;
&lt;li&gt;Pelican is a nice piece of software, allowing me to add new posts easily throuhg git and using&amp;nbsp;Markdown.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some issues that I had to find workarounds for include the fact that Pelican is not natively supported by Github Pages like Jekyll for example, and to be able to have search and some other things I&amp;rsquo;d need Pelican plugins, increasing a bit the complexity of using it. But it wasn&amp;rsquo;t enough to let me&amp;nbsp;down.&lt;/p&gt;
&lt;p&gt;One of the workarounds were the creation of a CircleCI workflow that generates the static site and commits to the proper branch of Github when I add a content to the work branch of the repo. This way, publishing the content wouldn&amp;rsquo;t anymore depend on me running pelican commands&amp;nbsp;locally.&lt;/p&gt;
&lt;p&gt;One question you may ask is why I decided to use Pelican instead of Jekyll or Hugo for&amp;nbsp;example?&lt;/p&gt;
&lt;p&gt;My thought in that case was simple. I wanted a python software for that. So if I ever need to bugfix or improve something, I&amp;rsquo;ll be working with the language I know the&amp;nbsp;most.&lt;/p&gt;
&lt;p&gt;Besides that, Pelican uses Jinja2 for then templates, and that&amp;rsquo;s a library I have already used and it kind of resembles the Django template system&amp;nbsp;too.&lt;/p&gt;
&lt;p&gt;So, here we are. A blog using Pelican to generate the static site, hosted on Github Pages and CircleCI to automate the publishing of the posts when I push&amp;nbsp;them.&lt;/p&gt;
&lt;p&gt;I hope you enjoyed this little post. If you would like to know more about how Pelican works or how to create your own blog using this setup, let me know in the comments&amp;nbsp;below!&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Blogging"></category><category term="Geral"></category><category term="Blogging"></category></entry><entry><title>Um novo começo</title><link href="http://programeempython.com.br/um-novo-comeco.html" rel="alternate"></link><published>2022-07-21T11:52:00+02:00</published><updated>2022-07-28T01:22:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-21:/um-novo-comeco.html</id><summary type="html">&lt;p&gt;Estamos aqui mais uma vez recome&amp;ccedil;ando este lindo blog que tem como intuito ensinar python e tamb&amp;eacute;m compartilhar um pouco das minhas experi&amp;ecirc;ncias e desafios com esta t&amp;atilde;o amada&amp;nbsp;tecnologia.&lt;/p&gt;
&lt;p&gt;Voc&amp;ecirc; pode esperar que este site tenha sempre conte&amp;uacute;dos de qualidade, e voc&amp;ecirc; pode tirar todas as d&amp;uacute;vidas diretamente comigo …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Estamos aqui mais uma vez recome&amp;ccedil;ando este lindo blog que tem como intuito ensinar python e tamb&amp;eacute;m compartilhar um pouco das minhas experi&amp;ecirc;ncias e desafios com esta t&amp;atilde;o amada&amp;nbsp;tecnologia.&lt;/p&gt;
&lt;p&gt;Voc&amp;ecirc; pode esperar que este site tenha sempre conte&amp;uacute;dos de qualidade, e voc&amp;ecirc; pode tirar todas as d&amp;uacute;vidas diretamente comigo nos coment&amp;aacute;rios ou redes sociais&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;At&amp;eacute; o pr&amp;oacute;ximo&amp;nbsp;post!&lt;/p&gt;</content><category term="Geral"></category><category term="Geral"></category></entry><entry><title>A new beggining</title><link href="http://programeempython.com.br/um-novo-comeco-en.html" rel="alternate"></link><published>2022-07-21T11:52:00+02:00</published><updated>2022-07-21T11:52:00+02:00</updated><author><name>Julio Melanda</name></author><id>tag:programeempython.com.br,2022-07-21:/um-novo-comeco-en.html</id><summary type="html">&lt;p&gt;Here I am once again starting this beautiful blog over aiming to teach python and also share some of my experiences and challenges with this beloved&amp;nbsp;technology.&lt;/p&gt;
&lt;p&gt;Here you can expect that this blog will have always quality content, and you can eliminate your doubts directly with me or on …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Here I am once again starting this beautiful blog over aiming to teach python and also share some of my experiences and challenges with this beloved&amp;nbsp;technology.&lt;/p&gt;
&lt;p&gt;Here you can expect that this blog will have always quality content, and you can eliminate your doubts directly with me or on social networks&amp;nbsp;:D&lt;/p&gt;
&lt;p&gt;See you in the next&amp;nbsp;post!&lt;/p&gt;</content><category term="Geral"></category><category term="Geral"></category></entry></feed>