File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- class Pessoa :
2- def __init__ (self , nome = None , idade = 35 ):
1+ class Pessoa : # Classe
2+ def __init__ (self , * filhos , nome = None , idade = 35 ): # Atributos da Classe
33 self .idade = idade
44 self .nome = nome
5+ self .filhos = list (filhos )
56
6- def cumprimentar (self ):
7- return f'Olá { id (self )} '
7+ def cumprimentar (self ): # Metódo da Classe
8+ return f'Olá { id (self )} ' # O método executa alguma coisa.
89
910
1011if __name__ == '__main__' :
11- p = Pessoa ('Luciano' )
12- print (Pessoa .cumprimentar (p ))
13- print (id (p ))
14- print (p .cumprimentar ())
15- print (p .nome )
16- p .nome = 'Renzo'
17- print (p .nome )
12+ renzo = Pessoa (nome = 'Renzo' )
13+ luciano = Pessoa (renzo , nome = 'Luciano' )
14+ print (Pessoa .cumprimentar (luciano ))
15+ print (id (luciano ))
16+ print (luciano .cumprimentar ())
17+ for filho in luciano .filhos :
18+ print (filho .nome )
19+
You can’t perform that action at this time.
0 commit comments