File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11class Pessoa :
2- def __init__ (self , nome = None , idade = 34 ):
2+ def __init__ (self , nome = None , idade = 34 , * filhos ):
33 self .nome = nome
44 self .idade = idade
5+ self .filhos = list (filhos )
56
67 def cumprimentar (self ):
78 return f'Olá { id (self )} '
89
910
1011if __name__ == '__main__' :
11- p = Pessoa ('Maia' )
12- print (Pessoa .cumprimentar (p ))
13- print (id (p ))
14- print (p .cumprimentar ())
15- print (p .nome )
16- p .nome = 'Fabiano'
17- print (p .nome )
18- print (p .idade )
12+
13+ jose = Pessoa (nome = 'Jose' , idade = 2 )
14+ maia = Pessoa ('Maia' , 30 , jose )
15+ fabiano = Pessoa (nome = 'Fabiano' , idade = 5 )
16+ maia = Pessoa ('Maia' , 30 , fabiano )
17+
18+ print (Pessoa .cumprimentar (maia ))
19+ print (id (maia .nome ))
20+ print ('1' , maia .cumprimentar ())
21+ print (maia .nome , maia .idade )
22+ print (maia .idade )
23+ print (str (maia .filhos .count ))
24+
25+ for filho in maia .filhos :
26+ print (Pessoa .cumprimentar (filho .nome ))
27+
28+ for filho in maia .filhos :
29+ print (filho .nome )
You can’t perform that action at this time.
0 commit comments