Skip to content

Commit b8d9e2c

Browse files
committed
Criados atributos de instância nome e idade
1 parent 0372521 commit b8d9e2c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

oo/pessoa.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +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('Luciano')
812
print(Pessoa.cumprimentar(p))
913
print(id(p))
1014
print(p.cumprimentar())
11-
12-
13-
14-
15+
print(p.nome)
16+
p.nome = 'Renzo'
17+
print(p.nome)
18+
print(p.idade)

0 commit comments

Comments
 (0)