Skip to content

Commit 0d47284

Browse files
criando e modificando atributos
1 parent 46b8260 commit 0d47284

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

oo/pessoa.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
class Pessoa:
2+
def __init__(self, nome=None): # atributos
3+
self.nome=nome
24
def cumprimentar(self):
3-
return f'Olá Mundo {id(self)}' # se verificar o id de self é o mesmo do p!
5+
return f'Olá Mundo {self.nome}' # se verificar o id de self é o mesmo do p!
46

57
if __name__ == '__main__':
6-
p= Pessoa()
8+
p= Pessoa('Teste') # chama a classe pessoas mandando a str Teste para nome
9+
print(p.cumprimentar() )
10+
#mudando atributos
11+
p.nome='Michel' # agora atribuindo a str Michel
712
print(p.cumprimentar())
8-
print(id(p))
913

1014

1115

0 commit comments

Comments
 (0)