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):
3+ # self.nome = nome
4+ # self.idade = idade
5+ #
6+ #
7+ # def cumprimentar(self):
8+ # return f'Olá {id(self)}'
9+ #
10+ #
11+ # if __name__ == '__main__':
12+ # p = Pessoa('Luciano')
13+ # print(Pessoa.cumprimentar(p))
14+ # print(id(p))
15+ # print(p.cumprimentar())
16+ # print(p.nome)
17+ # p.nome = 'charles'
18+ # print(p.nome)
19+ # print(p.idade)
20+
21+
22+ # ATRIBUTOS COMPLEXO
23+
124class Pessoa ():
2- def __init__ (self , nome = None , idade = 35 ):
25+ def __init__ (self , * filhos , nome = None , idade = 35 ):
326 self .nome = nome
427 self .idade = idade
28+ self .filhos = list (filhos )
529
630
731 def cumprimentar (self ):
832 return f'Olá { id (self )} '
933
1034
1135if __name__ == '__main__' :
12- p = Pessoa ('Luciano' )
13- print (Pessoa .cumprimentar (p ))
14- print (id (p ))
15- print (p .cumprimentar ())
16- print (p .nome )
17- p .nome = 'charles'
18- print (p .nome )
19- print (p .idade )
36+ renzo = Pessoa (nome = 'Renzo' )
37+ luciano = Pessoa (renzo , nome = 'Luciano' )
38+ print (Pessoa .cumprimentar (luciano ))
39+ print (id (luciano ))
40+ print (luciano .cumprimentar ())
41+ print (luciano .nome )
42+ print (luciano .idade )
43+ for filho in luciano .filhos :
44+ print (filho .nome )
2045
2146
2247
You can’t perform that action at this time.
0 commit comments