Skip to content

Commit 45f81a6

Browse files
author
cadica
committed
criado atributos de instância nome e idade
1 parent 18c3944 commit 45f81a6

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,9 +1,17 @@
11
class Pessoa:
2+
def __init__(self, nome=None, idade=50):
3+
self.nome = nome
4+
self.idade = idade
5+
26
def cumprimentar(self):
37
return f'Ola {id(self)}'
48

59
if __name__ == '__main__':
6-
p = Pessoa()
10+
p = Pessoa('Ricardo')
711
print(Pessoa.cumprimentar(p))
812
print(id(p))
913
print(p.cumprimentar())
14+
print(p.nome)
15+
p.nome = 'Arruda'
16+
print(p.nome)
17+
print(p.idade)

0 commit comments

Comments
 (0)