11class Pessoa :
2-
32 olhos = 2
43
54 def __init__ (self , * filhos , nome = None , idade = 35 ):
@@ -10,7 +9,7 @@ def __init__(self, *filhos, nome=None, idade=35):
109 def cumprimentar (self ):
1110 return f'Olá { id (self )} '
1211
13- #metodos de Classe
12+ # metodos de Classe
1413 @staticmethod
1514 def metodo_estatico ():
1615 return 42
@@ -19,11 +18,16 @@ def metodo_estatico():
1918 def nome_e_atributos_de_classe (cls ):
2019 return f'{ cls } - olhos { cls .olhos } '
2120
21+
22+ class Homem (Pessoa ):
23+ pass
24+
25+
2226if __name__ == '__main__' :
2327 sofia = Pessoa (nome = 'Sofia' )
2428 valentina = Pessoa (nome = "Valentina" )
25- jacir = Pessoa (sofia , nome = 'Jacir' )
26- jacir = Pessoa (valentina , nome = 'Jacir' )
29+ jacir = Homem (sofia , nome = 'Jacir' )
30+ jacir = Pessoa (valentina , nome = 'Jacir' )
2731 print (Pessoa .cumprimentar (jacir ))
2832 print (id (jacir ))
2933 print (jacir .cumprimentar ())
@@ -32,7 +36,6 @@ def nome_e_atributos_de_classe(cls):
3236 for filho in jacir .filhos :
3337 print (filho .nome )
3438
35-
3639 # atributos dinâmicos - criados em tempo de execução
3740
3841 jacir .sobrenome = 'Pieniak'
@@ -42,26 +45,20 @@ def nome_e_atributos_de_classe(cls):
4245 del jacir .sobrenome
4346 print (jacir .__dict__ )
4447
45- # teste atributos de classe
48+ # teste atributos de classe
4649
4750 print (Pessoa .olhos )
4851 print (jacir .olhos )
4952 jacir .olhos = 3
5053 print (jacir .__dict__ )
5154
52- # teste metodos de classe
55+ # teste metodos de classe
5356
5457 print (id (Pessoa .olhos ), id (jacir .olhos ))
5558 print (Pessoa .metodo_estatico (), jacir .metodo_estatico ())
5659 print (Pessoa .nome_e_atributos_de_classe (), jacir .nome_e_atributos_de_classe ())
5760
61+ # teste Herança
5862
59-
60-
61-
62-
63-
64-
65-
66-
67-
63+ print (isinstance (sofia , Pessoa ))
64+ print (isinstance ())
0 commit comments