Skip to content

Commit a4ad4d8

Browse files
author
Matheus
committed
criado atributo de instância nome e idade
1 parent 422aee9 commit a4ad4d8

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

oo/pessoa.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
class Pessoa:
2-
pass
2+
3+
def __init__(self, nome=None, idade=35):
4+
self.nome = nome
5+
self.idade = idade
6+
7+
def cumprimentar(self):
8+
return f'Olá {id(self)}'
9+
10+
11+
if __name__ == '__main__':
12+
p = Pessoa('Luciano')
13+
print(Pessoa.cumprimentar(p))
14+
print(id(p))
15+
print(p.cumprimentar())
16+
print(p.nome)
17+
p.nome = 'Renzo'
18+
print(p.nome)
19+
print(p.idade)

0 commit comments

Comments
 (0)