Skip to content

Commit 06d6aea

Browse files
committed
Criado atributo de instancia nome e idade
1 parent 8250978 commit 06d6aea

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

OO/pessoa.py

Lines changed: 10 additions & 2 deletions
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.nome = nome
4+
self.idade = idade
5+
26
def cumprimentar(self):
37
return f'Olá {id(self)}'
48

59

610
if __name__ == '__main__':
7-
p = Pessoa()
11+
p = Pessoa('André')
812
print(Pessoa.cumprimentar(p))
913
print(id(p))
10-
print(p.cumprimentar())
14+
print(p.cumprimentar())
15+
print(p.nome)
16+
p.nome = 'Victor'
17+
print(p.nome)
18+
print(p.idade)

0 commit comments

Comments
 (0)