Skip to content

Commit 7cae2ec

Browse files
criado atributo complexo filhos
1 parent 3239ab1 commit 7cae2ec

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

oo/pessoa.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
class Pessoa:
2-
def __init__(self, nome=None, idade=27): # atributos
2+
def __init__(self,*filhos, nome=None, idade=27): # atributos
3+
self.nome = nome
34
self.idade = idade
4-
self.nome=nome
5+
self.lfi=list(filhos)
6+
7+
8+
59
def cumprimentar(self):
610
return f'Olá Mundo {self.nome}' # se verificar o id de self é o mesmo do p!
711

812
if __name__ == '__main__':
9-
p= Pessoa('Teste') # chama a classe pessoas mandando a str Teste para nome
10-
print(p.cumprimentar() )
13+
daniele= Pessoa(nome='Daniele') # chama a classe pessoas mandando a str Teste para nome
14+
michel= Pessoa(daniele, nome='Michel')
15+
for i in michel.lfi:
16+
print(i.nome)
17+
# print(cadastro.cumprimentar())
1118
#mudando atributos
12-
p.nome='Michel' # agora atribuindo a str Michel.
13-
print(p.cumprimentar(),p.idade)
19+
#cadastro.nome= 'Michel' # agora atribuindo a str Michel.
20+
# print(cadastro.cumprimentar(), cadastro.idade)
1421

0 commit comments

Comments
 (0)