`
linguagem` `
topico` `
nome`Python 3.0`
` `
titulo`Python 3.0: Diagrama Sintático - Diagrama de Sintaxe, BNF, Comandos, Exemplos`
` `
descritor`apoie, apoie.org, Python, file_input, single_input, eval_input, stmt, if_stmt, while_stmt, for_stmt, with_stmt, decorator, classdef, funcdef, small_stmt, expr_stmt, flow_stmt, import_stmt, import_from, import_as_names, try_stmt, except_clause, typedargslist, name_test, tfpdef, test, suite, arglist, argument, varargslist, name_test_list, yield_expr, or_test, expr, atom, testlist_comp, dictorsetmaker, trailer, subscript, dotted_as_names, comp_for, test_nocond, BNF, Diagrama Sintático - Diagrama de Sintaxe, Exemplo, Comandos, Linguagem, Filtro, xml, sintaxe, sintaxe original, desenho, programação`
` `
lead`Sintaxes representadas por Diagrama Sintático - Diagrama de Sintaxe gerados a partir de BNF .`
` `
link`Python Diagrama Sintático - Diagrama de Sintaxe Original wikipedia`
` `
link` Genial: http://www.pythontutor.com - Digite seu próprio código e veja "graficamente" como ele é executado no seu computador. Dica de rodrigodelimavieiraatgmail.com 20set2012 `
` `
origem`Python3.xml`
` `
referencia`~DSGerador~`
` `
fonte`http://www.python.org/doc/3.0/reference/grammar.html`
` `
` `
topico` `
titulo`print`
` `
bnf`print"([expr(","expr)*[","]] 
` `
desc`

`
` `
exemplo`
print('para instalar o python faça Download do ambiente livre Python 3.4 Anaconda: http://continuum.io/downloads' )

para instalar o python faça Download do ambiente livre Python 3.4 Anaconda: http://continuum.io/downloads

saida= 'para instalar o ambiente Python 3.4 Anaconda faça Download: http://continuum.io/downloads'
print(saida)
para instalar o ambiente Python 3.4 Anaconda faça Download: http://continuum.io/downloads


saida2='nesta string eu tenho aspas simples (\') e aspas duplas(")' 
print(saida2)

nesta string eu tenho aspas simples (') e aspas duplas(")

print('um comando' + ' ' + 'que ocupe' + ' ' + 'duas ou mais linhas')

um comando que ocupe duas ou mais linhas

texto = '''There are two candidates for the TIOBE programming language of the year award that will 
be announced around the 1st of January 2015. These are statistical language R (+1.38%) and Apple's
new .....'''
print(texto)

There are two candidates for the TIOBE programming language of the year
award that will be announced around the 1st of January 2015. These are
statistical language R (+1.38%) and Apple's new.....

texto

"\nThere are two candidates for the TIOBE programming language of the
year award that will be announced around the 1st of January 2015. These
are statistical language R (+1.38%) and Apple's new ...."

print('tamanho do texto é:'len(texto))  
tamanho do texto é:510


` `
` `
topico` `
titulo`file_input`
` `
bnf`[(NEWLINE | stmt)+] ENDMARKER`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 file_input`
` `
` `
topico` `
titulo`single_input`
` `
bnf`stmt? NEWLINE`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 single_input`
` `
` `
topico` `
titulo`eval_input`
` `
bnf`test {',' test} ','? [NEWLINE+] ENDMARKER`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 eval_input`
` `
` `
topico` `
titulo`stmt`
` `
bnf`small_stmt (';' small_stmt)* ';'? |if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | [decorator+] (classdef | funcdef)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 stmt`
` `
` `
topico` `
titulo`if_stmt`
` `
bnf`'if' [(test ':' suite 'elif')+] test ':' suite ['else' ':' suite]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 if_stmt`
` `
exemplo`
x=10
if x < 0:
x = 0
print ('Negative changed to zero')
elif x == 0:
print ('Zero')
elif x == 1:
print ('Single')
else:
print ('More')



More
`
` `
` `
topico` `
titulo`while_stmt`
` `
bnf`'while' test':' suite ['else' ':' suite]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 while_stmt`
` `
exemplo`
# Fibonacci series:
# the sum of two elements defines the next
a, b = 0, 1
while b < 10:
print (b)
a, b = b, a+b

1
1
2
3
5
8
`
` `
` `
topico` `
titulo`for_stmt`
` `
bnf`'for' '*'? expr (',' '*'? expr)* ','? 'in' test (',' test)* ','? ':' suite['else' ':' suite]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 for_stmt`
` `
exemplo`
# Measure some strings:
a = ['cat', 'window', 'defenestrate']
for x in a:
print (x, len(x))
cat 3
window 6
defenestrate 12
`
` `
` `
topico` `
titulo`with_stmt`
` `
bnf`'with' test [ 'as' expr ] ':' suite`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 with_stmt`
` `
` `
topico` `
titulo`decorator`
` `
bnf`'@' NAME ('.' NAME)* [ '(' arglist')' ] NEWLINE`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 decorator`
` `
` `
topico` `
titulo`classdef`
` `
bnf`'class' NAME ['(' arglist ')'] ':' suite`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 classdef`
` `
` `
topico` `
titulo`funcdef`
` `
bnf`'def' NAME '(' typedargslist')'['->' test] ':' suite`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 funcdef`
` `
` `
topico` `
titulo`small_stmt`
` `
bnf`expr_stmt | 'del' '*'? expr (',' '*'? expr)* ','? | 'pass'| flow_stmt | import_stmt | ('global '|' nonlocal') NAME (',' NAME)* |'assert' test [',' test]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 small_stmt`
` `
` `
topico` `
titulo`expr_stmt`
` `
bnf`test (',' test)* ','? ('+ - * / ** & | ^ < < > > //' '=' (yield_expr | test (',' test)* ','?)|('=' (yield_expr | test (',' test)* ','?))+ | "")`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 expr_stmt`
` `
` `
topico` `
titulo`flow_stmt`
` `
bnf`'break'| 'continue' | 'return' [test (',' test)* ','?] | 'raise' [test ['from' test]] | yield_expr`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 flow_stmt`
` `
` `
topico` `
titulo`import_stmt`
` `
bnf`'import' dotted_as_names | import_from`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 import_stmt`
` `
` `
topico` `
titulo`import_from`
` `
bnf`'from' ([('.' | '...')+] NAME ('.'NAME)* | ('.' |'...')+) 'import' ('*' | '(' import_as_names ')' | import_as_names)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 import_from`
` `
` `
topico` `
titulo`import_as_names`
` `
bnf`NAME ['as' NAME] (',' NAME ['as' NAME])* ','?`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 import_as_names`
` `
` `
topico` `
titulo`try_stmt`
` `
bnf`'try' ':' suite((except_clause ':' suite)+ ['else' ':' suite] ("" | 'finally' ':' suite) | 'finally' ':' suite)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 try_stmt`
` `
` `
topico` `
titulo`except_clause`
` `
bnf`'except' [test ['as' NAME]]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 except_clause`
` `
` `
topico` `
titulo`typedargslist`
` `
bnf`([name_test ',']('*' tfpdef? [',' name_test] [',' '**' tfpdef] | '**' tfpdef) | name_test? ','?)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 typedargslist`
` `
` `
topico` `
titulo`name_test`
` `
bnf`tfpdef ['=' test] (',' tfpdef ['=' test])*`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 name_test`
` `
` `
topico` `
titulo`tfpdef`
` `
bnf`NAME [':' test]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 tfpdef`
` `
` `
topico` `
titulo`test`
` `
bnf`or_test ['if' or_test 'else' test] | 'lambda' varargslist ':' test`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 test`
` `
` `
topico` `
titulo`suite`
` `
bnf`small_stmt (';' small_stmt)* [';'] NEWLINE | NEWLINE INDENT stmt+ DEDENT`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 suite`
` `
` `
topico` `
titulo`arglist`
` `
bnf`(argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 arglist`
` `
` `
topico` `
titulo`argument`
` `
bnf`test (comp_for? | test '=' test)`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 argument`
` `
` `
topico` `
titulo`varargslist`
` `
bnf`name_test_list ',' ('*' [NAME] [',' name_test_list] [',' '**' NAME] | '**' NAME)| name_test_list [',']`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 varargslist`
` `
` `
topico` `
titulo`name_test_list`
` `
bnf`NAME ['=' test]{',' NAME ['=' test]}`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 name_test_list`
` `
` `
topico` `
titulo`yield_expr`
` `
bnf`'yield' [test (',' test)* ','?]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 yield_expr`
` `
` `
topico` `
titulo`or_test`
` `
bnf`('not'+)? '*'? expr("< | > | == | >= | <= | != | in | not in | is | is not" '*'?expr)* (('and' | 'or') ('not'+)? '*'? expr("< | > | == | >= | <= | != | in | not in | is | is not" '*' ?expr)*)*`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 or_test`
` `
` `
topico` `
titulo`expr`
` `
bnf`'+ | - | ~'? atom [trailer+]('+ - * / % ** & | ^ << >> //' '+ | - | ~'? atom [trailer+])*`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 expr`
` `
` `
topico` `
titulo`atom`
` `
bnf`('(' ([yield_expr]|testlist_comp) ')'|'['testlist_comp']'|'{'dictorsetmaker '}' |NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 atom`
` `
` `
topico` `
titulo`testlist_comp`
` `
bnf`[test (comp_for | [(',' test)+] [','])]`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 testlist_comp`
` `
` `
topico` `
titulo`dictorsetmaker`
` `
bnf`test ( (':' test (comp_for |[(',' test ':' test)+] ','?)) |[(comp_for | ',' test)+] ','? )`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 dictorsetmaker`
` `
` `
topico` `
titulo`trailer`
` `
bnf`'(' arglist ')' | '[' subscript (','subscript)* ','? ']' |'.' NAME`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 trailer`
` `
` `
topico` `
titulo`subscript`
` `
bnf`test | [test] ':' test? (':' test?)?`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 subscript`
` `
` `
topico` `
titulo`dotted_as_names`
` `
bnf`NAME ('.' NAME)* ['as' NAME](',' NAME ('.' NAME)*['as' NAME])*`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 dotted_as_names`
` `
` `
topico` `
titulo`comp_for`
` `
bnf`('for' '*'? expr (',' '*'? expr)* ','? 'in' or_test [('if'test_nocond)+])+`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 comp_for`
` `
` `
topico` `
titulo`test_nocond`
` `
bnf`or_test | 'lambda' varargslist ':' test_nocond`
` `
desc`Diagrama Sintático - Diagrama de Sintaxe Python 3.0 test_nocond`
` `
` `
`