We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ca2c8b commit b8c66c7Copy full SHA for b8c66c7
1 file changed
oo/pessoa.py
@@ -1,17 +1,20 @@
1
class Pessoa:
2
- def __init__(self, nome=None, idade=35):
+ def __init__(self, *filhos, nome=None, idade=35):
3
self.idade = idade
4
self.nome = nome
5
+ self.filhos = list(filhos)
6
7
def cumprimentar(self):
8
return f'Olá {id(self)}'
9
10
if __name__ == '__main__':
- p = Pessoa('Luciano')
11
- print(Pessoa.cumprimentar(p))
12
- print(id(p))
13
- print(p.cumprimentar())
14
- print(p.nome)
15
- p.nome = 'Cliver'
16
17
- print(p.idade)
+ cliver = Pessoa(nome='cliver')
+ luciano = Pessoa(cliver, nome='luciano')
+ print(Pessoa.cumprimentar(luciano))
+ print(id(luciano))
+ print(luciano.cumprimentar())
+ print(luciano.nome)
+ print(luciano.idade)
18
+ for filho in luciano.filhos:
19
+ print(filho.nome)
20
+
0 commit comments