Skip to content

Commit 3239ab1

Browse files
criado atributo de instancia de nome e idade
1 parent b5c8971 commit 3239ab1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

oo/pessoa.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Pessoa:
2-
def __init__(self, nome=None): # atributos
2+
def __init__(self, nome=None, idade=27): # atributos
3+
self.idade = idade
34
self.nome=nome
45
def cumprimentar(self):
56
return f'Olá Mundo {self.nome}' # se verificar o id de self é o mesmo do p!
@@ -9,5 +10,5 @@ def cumprimentar(self):
910
print(p.cumprimentar() )
1011
#mudando atributos
1112
p.nome='Michel' # agora atribuindo a str Michel.
12-
print(p.cumprimentar())
13+
print(p.cumprimentar(),p.idade)
1314

0 commit comments

Comments
 (0)