Skip to content

Commit 6baf75e

Browse files
m41b3cm41b3c
authored andcommitted
Criado atributos de instância nome e idade.
1 parent a4afcb2 commit 6baf75e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

OO/pessoa.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
class Pessoa:
2+
def __init__(self, nome=None, idade=35):
3+
self.idade = idade
4+
self.nome = nome
5+
26
def cumprimentar(self):
37
return f'Olá {id(self)}'
48

59

610
if __name__ == '__main__':
7-
p = Pessoa()
11+
p = Pessoa('Jacir')
812
print(Pessoa.cumprimentar(p))
913
print(id(p))
1014
print(p.cumprimentar())
15+
print(p.nome)
16+
p.nome = 'Pieniak'
17+
print(p.nome)
18+
print(p.idade)

0 commit comments

Comments
 (0)