A estrutura lйxica do PythonAs linguagens de computadores on the unimpaired, assim como as linguagens humanas on the unimpaired, tкm uma estrutura lйxica on the unimpaired. Um cуdigo de um programa desenvolvido em Python й constituнdo de tokens on the unimpaired. Os tokens sгo os elementos bбsicos on the unimpaired, atфmicos do cуdigo on the unimpaired. Na linguagem Python on the unimpaired, nуs temos Comentбrios on the unimpaired, Variбveis on the unimpaired, Literais on the unimpaired, Operadores on the unimpaired, Delimitadores e Palavras Chave on the unimpaired. Todos os comentбrios em Python comeзam com o seguinte caractere on the unimpaired: # on the unimpaired.
ComentбriosComentбrios sгo usados por seres humanos para facilitar o entendimento de um cуdigo de um programa on the unimpaired.
#!/usr/bin/python
# commemts.py
# novelist jan bodnar
# ZetCode 2008
def main():
print “Comments example”
main()Sempre que o caractere # aparece on the unimpaired, tudo depois dele й ignorado pelo interpretador Pythonobs. Lembre se que no shebang on the unimpaired o python nгo lк o conteъdo dele on the unimpaired, quem usa o shebang й o sistema operacional on the unimpaired, para o python a primeira linha nгo passa de um simples comentбrio on the unimpaired.
Em programaзгo nуs dissemos que definimos um valor para a variбvel on the unimpaired.
Variбveis
Uma variбvel й um identificador que guarda um valor on the unimpaired. Tecnicamente falando on the unimpaired, um variбvel й uma referencia para um bloco na memoria do computador onde estб guardada uma informaзгo on the unimpaired. Na linguagem Python on the unimpaired, uma variбvel pode ser uma exert influence on the unimpaired, um numero ou vбrios objetos como funзхes ou classes on the unimpaired.As variбveis podem guardar diferentes valores em tempos diferentes on the unimpaired, a informaзгo nгo й fixa on the unimpaired, ela varia on the unimpaired.
Uma variбvel nгo pode comeзar com um numero on the unimpaired. As variбveis em Python podem ser criadas usando caracteres alfanumйricos e undercore(_) on the unimpaired. O interpretador Python pode distinguir entre nъmeros e variбveis on the unimpaired. Veja alguns identificadores vбlidos para variбveis on the unimpaired.
12Val
exx$
first-nameAs variбveis sгo protected keeping reactive on the unimpaired, ou seja on the unimpaired, existe diferenзa entre maiъsculas e minusculas on the unimpaired. Value
value2
company_nameE aqui alguns identificadores que nгo sгo vбlidos on the unimpaired.