We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c34012 commit 6d97219Copy full SHA for 6d97219
1 file changed
oo/pessoa.py
@@ -1,9 +1,14 @@
1
class Pessoa:
2
+ # Atributos de classe ou atributo default
3
+ olhos = 2
4
+
5
+ # Atributos de instância
6
def __init__(self, *filhos, nome="Gustavo", idade=35):
7
self.idade = idade
8
self.nome = nome
9
self.filhos = list(filhos)
10
11
+ # Método
12
def cumprimentar(self):
13
return f"Olá, {self.nome}!"
14
@@ -17,7 +22,7 @@ def cumprimentar(self):
17
22
for i, filho in enumerate(pai.filhos):
18
23
print(f"O {i+1}º chama {filho.nome}.")
19
24
20
- pai.sobrenome = "Souza"
25
+ pai.sobrenome = "Souza" # Atributo criado dinamicamente
21
26
print(pai.nome, pai.__dict__)
27
print(filho01.nome, filho01.__dict__)
28
0 commit comments