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