We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6baf75e commit 05d1eefCopy full SHA for 05d1eef
1 file changed
OO/pessoa.py
@@ -1,18 +1,22 @@
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
11
if __name__ == '__main__':
- p = Pessoa('Jacir')
12
- print(Pessoa.cumprimentar(p))
13
- print(id(p))
14
- print(p.cumprimentar())
15
- print(p.nome)
16
- p.nome = 'Pieniak'
17
18
- print(p.idade)
+ sofia = Pessoa(nome='Sofia')
+ valentina = Pessoa(nome="Valentina")
+ jacir = Pessoa(sofia, nome='Jacir')
+ jacir = Pessoa(valentina, nome = 'Jacir')
+ print(Pessoa.cumprimentar(jacir))
+ print(id(jacir))
+ print(jacir.cumprimentar())
19
+ print(jacir.nome)
20
+
21
+ for filho in jacir.filhos:
22
+ print(filho.nome)
0 commit comments