Skip to content

Commit 5932902

Browse files
committed
criando atributos de instância, nome e idade.
1 parent 8def53b commit 5932902

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=34):
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('Maia')
812
print(Pessoa.cumprimentar(p))
913
print(id(p))
10-
print(p.cumprimentar(p))
14+
print(p.cumprimentar())
15+
print(p.nome)
16+
p.nome ='Fabiano'
17+
print(p.nome)
18+
print(p.idade)

0 commit comments

Comments
 (0)