Escolar Documentos
Profissional Documentos
Cultura Documentos
Pythonoo PDF
Pythonoo PDF
"
#$
&$
'( )
* + ), -
!+
!"#$
%
!
( )$ *
"
'&
'&
' $
( )$
$%&
'&
(
( * , ,+
(
(
%&
)
*
"
(
(
--- %& .*
+
!
"
$%&
*+
* 1
30 !
5
"
*)
*"
1
$&'"#$
$%&
5
2
6
!
30
&
'&
!
(
(
---
*+
&
7
! &"
1 30
4
0
7 ! 8
"
92
$%&
&
;< 2$
:
=& 2
labaki@feis.unesp.br
woiski@dem.feis.unesp.br
+ &,
-
( )$
>? *
!&$ ! ./ $
A$
&
C2
BF
!
12
!
3$ ./ $ 24
>2
A
1
*
>@
>I
AA
! "!
67
$ 9'
1$ <
8 4 !@
A
A
A
5
I
"=
? -@
-,
$
! 12
!
$.
:;
$4
0>
0>
0:
>A
( )$
>
!. 4'
!&$! ./ $
30
$%&
*)
*
37 !
5"
!
1
30
*)
'
*
'
$%&
!
!
L 0
*)
"
8 !
$%&
!
*
)
30
" !
*
"
"
K"
*
"
'
M
"
"
30
"
*)
$%&
*)
Aluso clebre frase Habemus Papa!, proclamada por um cardeal na baslica de So Pedro (Vaticano)
sempre que um novo papa acaba de ser eleito.
6A
,
4 ,!
!,
<!3' ! &$&
1
2
'
)$ A
30
*)
30
30
.
+
!
"
) !
30
$
"
&
37
<
* 1
"
30
1
30
"
M
"
30
*)
*
!
<0
37
*)
!
!
*)
*)
"
*)
&
&
<0
>
&
*
*)
C <
*)
<
30
"
<
*)
0+
:A
'
*)
C' &!
!,
<!3 ? 4 2
$ &$4' &$
!2
A
&
30
30
"
<
!
0
0
)
*
"
*
.
!
! 7
.
K
!)
"
*
!
*)
Mensagem: alimente-se!
/
8
K!
*) !
"
&
0+
!
)
'
'
& *8
0+
!
'
*)
1 30 !)
"
30
*)
8
!
&
8
0
&
!
&
*)
"
"
0A
<
*)
8
K
- ,!
!,
<!3
$-D&,
C$A
a = sqrt(b)
=
"
30
$
!
30
30
& 2 "
*)
"
$%& G
a = b.sqrt()
"
*)
*
1
$
GJ )
&
>>> a='araraquara'
>>> a.split('a')
['', 'r', 'r', 'qu', 'r', '']
<
!
30
*)
'
!
*)
30
*)
'a'
30
&
*)
*)
>>> dir(a)
['__add__',
'__class__',
'__contains__',
'__delattr__',
'__doc__',
'__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__',
'__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__str__',
'capitalize',
'center',
'count',
'decode',
'encode',
'endswith',
'expandtabs',
'find',
'index',
'isalnum',
'isalpha',
'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust',
'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip',
'split',
'splitlines',
'startswith',
'strip',
'swapcase',
'title',
'translate', 'upper', 'zfill']
30
&
&
*
&
*)
*)
*
DA
)
)
&
37
"
=
/5
7A
9'! !
! ,<!3
30
E'
!G, !2H
*)
"
&
*)
&
'
#
/8
)
"
*)
30
*)
!*
0L 0
18
".
"
30
. &
"
<
%
%
"
&
b=[1,2,3]' (
a='araraquara'
* #
b.reverse()
+
"
")
a.upper()
, '- .
"
$
#
/ %
*
12!
3 $ ./ $ 2 4
*)
)
"
! *)
0
37
'
!
&
*)
30
8
+!
*)
30
*)
0
30
'
0
+
:
!
$%& ! 0
!
37 !
&
$%&
"
30
>A
*)
*)
J)
"
!? A
30
$%&
"
class
pass
!*
"
&
9J )
10
>>> Cachorros
<class __main__.Cachorros at 0x00B04360>
&
30 * !
)
"
>>> dir(Cachorros)
['__doc__', '__module__']
:
2
)
"
*)
0
1
"
!' <
&
0
Cachorros()!
'
30
+ <0
>>> Cachorros ()
<__main__.Cachorros instance at 0x00CF3D50>
30
3
3!
".
'
&1
*)
+
30
11
37
&
0 2
!
!
*
0
&,
! ! 0 &"
.
:
2*
K
*
!!
30
* 30 !
$%& !
* 8
J)
&
d = Cachorros ()
0
K
37 ! &
"
*)
"
"
!
$%&
# O mesmo id de Cachorros!
>>> Dogs.__name__
'Cachorros'
!
!
37
*)
*)
30
. !
!*
12
try:
print 'Nome do objeto: %s. Id: %d.' % (c.__name__, id(c))
except:
print """O objeto " %s " no tem atributo __name__
mas seu id %d."""
% (str(c), id(c))
>>> ndo=nome_do_objeto
>>> ndo(Dogs)
Nome do objeto: Cachorros. Id: 10756032.
>>> ndo('abacaxi')
O objeto " abacaxi " no tem atributo __name__
mas seu id 10738400.
$
5
'0
+
!
30
! 0
)
TT
$%& !
*)
0
8
TT 2
&
,
#
0
*)
*
F
37 !
8 !
30
#
#
")
ndo(ndo)' (
/
'
&
"
4
$
/
$ ./
13
6A
,.' $
*
:
4F $&$ A
*)
)!
&
8
0
7
J)
&
:
>>> dir(Cachorros)
['__doc__', '__module__', 'alimento', 'cobertura', 'habitat', 'nome', 'patas']
>>> dir(Galinhas)
14
1
*
*
*
3
8
>>> Snoopy=Cachorros()
>>> Lala=Galinhas()
>>> Snoopy.alimento
'carne'
>>> Lala.alimento
'graos'
>>> Lala.bico
'pequeno'
>>> Snoopy.bico
&
&
!0
15
;9
"
%G P
* 8 N
%.
&
'
*
30
:
!
R
6 1S
9
>>> Cachorros.nome
'Rex'
0
:
0
37
'
*
0
:
<
8
37
1
!1
;
16
!
=
* 8
!
;
*
*
>!
1
0
>
!
"
>>> C1=Circulos()
>>> C1.raio
25.399999999999999
>>> C1.area
>>> C1.calcula_Area()
>>> C1.area
2025.8024
>>> dir(C1)
['__doc__', '__module__', 'area', 'calcula_Area', 'calcula_Volume', 'raio']
"
T
37
"
"
GGGS '
*
& G, ,"#$
17
<
"
&
"
>!
C1.area = 3.14*(C1.raio**2)
"
13'
1>
*
!
*
"
>!
=
1
'
13'
;
*
!
*
13!
0
"
!
0
$%&
"
?"
"
!
!
"
1 8
>>> C1 = Circulos()
>>> C1.calcula_Volume()
18
*
1
"
>>> C1.Calcula_Volume(12.)
>>> C1.volume
24309.628799999999
4
AB@9
!&
"
G
"!
R
2
%S
+
'
!TT
-,!2
K
*
TT
30
&
=
'
>
& K
$ 4$4
:
)
"
8
&
4F $&$
<
8
:
&
!R
6 1S
:A
"
G;
!
30 6
&
$ 4 E'
!
2! G$ - ,!&!
8
&
19
self.nome= nome
>>> d1 = Cachorros('Dog1')
>>> d1.nome
'Dog1'
0
1
30
<
!
0 ' "
!
*)
!
"
&!
'
1!
%+
)
"
W 1 > ;
&
"
30
>W1>W $
<
S
!
30
30
8
+
"
"
20
self.nome = nome
self.tamanho = tamanho
self.cor = cor
self.arestas = arestas
def update_position(self):
self.position = random()*10,random()*10 # posies x e y
print '%s est agora em %s.' %(self.nome,self.position)
<
"
30
)!
>!
1
:
A
!
)
)
"
37
21
J
:
30
"
K
:
&
*
.
*
3
$
?
;
#
0A
(None, None)
")
@5
;'- .
) /
! ,.' $
-,!,
!
!
!
37 !
$%&
*
*
22
&
!
N
J)
23
30
)
"&
30 !
4
30
30
)
&
1*
$
!
&
1*
30
"
! R
>>> help(Fausto)
Help on class Fausto in module __main__:
class Fausto
|
|
|
|
|
review(self)
B$
"
Fausto.__doc__
Fausto().__doc__/
=
/5 !
3'
+!
"9
9
:
:
'
)!
3
"
:
)
6
=
/5
24
! "!
*
&
$%&
&
&
&
J)
3!
8
4
&
K
!
/
3
8
3
:
.
&
0
8
G
25
20
<0
&
!
<
&
&
K
'
'$
S
+
R S
!R
K!
$%& !
'
#
6
3!
! K.
S
!
R
*
'
R &S
!
'
K
&
S
+
9
+!
&
class Condutores_Trmicos:
atributos1....
class Materiais_Ferrosos(Condutores_Trmicos):
atributos2.....
class Materiais_Dcteis(Materiais_Ferrosos):
atributos3.....
!
@
/
@
CD
;
6
&
&
&
9
0 &
3
!
! &
!2
!&
26
J)
&
L A
K&
6
X
;" &
1
K
*
*
!
!!
;"'
)
4
0
&
"
;" &
*
J)
K
27
*
2
6
&
!2
'
>>> issubclass(Neta,Pai)
True
>>> Neta.__bases__
(<class __main__.Filha at 0x00A48030>,)
&
.*
"
28
'
J
&
$%&
* 1 G=
&
&
+
*
&
!
<
:
;
*
1!
K
&
.
"
$%&
1
*)
!
J
Z!.
*)
*)
!
30
:
*
.
!
[ (!
J
' 8
R&
:
K
"
S
+
29
# mtodo especial!
# mtodo espeial!
>>> a = Op_Basicas(56)
>>> b = Op_Basicas(-23)
>>> a + b
33
>>> a * b
-1288
&
PK
!
!
!
*
*
"
'
:
*
!
0
30
30
9<0
30
)
"
30
"
$%&
!
0
!
3(
"
K 30
?
4
)
1 30
1 30
N
2
*
"&*
*)
"!
9J
<
3
!
2)
;
0
!
*
3
31
# mtodo especial!
&
"
$
"
"5 /(
"
&
/ E4
/
>>> c = Op_Avancadas(4)
>>> c / a
0.071428571428571425
>>> c / b
-0.17391304347826086
>>> c + a
60
>>> c * b
-92
J)
30
&
*
3!
*
:
32
&
*
P
!
.*
* 1 &
>>> d = Op_Extras(6)
>>> d.quadrado()
36
>>> d + a
62
>>> c + d
10
>>> d / b
-0.2608695652173913
&
TT
! TT
"! 1
F+
3!
!
TT
! !)
"
&
30
'
D+
20
4
&
$%&
$
*)
0
K
*
"
33
30 *
*)
* *) !
&
K.
30
:
:
!
# mtodo especial!
return qualquer_coisa
34
>>> a = Op_Basicas(56)
>>> a('Vejam, eu sou uma instncia callable')
Vejam, eu sou uma instncia callable
>>> b = Op_Avancadas(-23)
>>> b('Eu tambm sou!')
Eu tambm sou!
>>> d = Op_Extras(6)
>>> d('E eu, ento, no sou?')
E eu, ento, no sou?
>>> a(a.valor), a(b.valor), b(d.valor)
(56, -23, 6)
>>> callable(a), callable(b), callable(d)
(True, True, True)
*)
:
$
30
!
&
3 !
30
:
;
*
"
"
&
F+
!
*
)
"
TT
F+
4 B
Op_Basicas('abacaxi')(6) * Op_Extras(16)('bola')
35
"
3
print inst1!
1
30
30
# mtodo especial!
self.valor = entrada
def __call__(self, qualquer_coisa):
# mtodo especial!
return qualquer_coisa
def __str__(self):
# mtodo especial!
>>> a = Op_Basicas(56)
>>> print a
Sou uma orgulhosa instncia de __main__.Op_Bsicas
>>> a('Hello!')
'Hello!'
>>> b = Op_Avancadas('abacaxi')
>>> print b
Sou uma orgulhosa instncia de __main__.Op_Avancadas
>>> d = Op_Extras(6)
>>> print d
Sou uma orgulhosa instncia de __main__.Op_Extras
>>> b(a.valor)
56
36
! )
"
TT
1
8
3
30
$%&
30
*)
&
!
<0
$G.
0
"
K
"
K &
<0
$ E'
!!
1
O
! 12
!
%
$%&
)
30
/
30
30
*)
!
!
*)
37
J)
37
'
'
'
E '
'
'(
7
$
+
4
#
-
+ /;
"
7
'
H
4 B
38
$
C4
*
"
")
'
4
!B
39
# as instncias so imprimveis
idade: 35
sexo: masculino
nome: Oliveira
>>> print nf
# as instncias so imprimveis
preo: 300.0
produto: carro
nome: Cardoso
30
* &
)
!
40
1$ <
"=
$.
'
30
$4
<0
30
!
$%&
"
"
2
30
J)
37
"
L
2
!
<
'
30 +
*
!
A!
&
8 I
? -@
-,
$
P"
1
&
$%&
41
&
>WW
)\ >! A! C!
&
&
U
/
"
! >WW!
2
CC
K
'
0
V
!
+
!
8
37
30
"
CC
6
"
&
* &
)
30
2*
37
(a + bi ) (c + di ) = (a c) + (b d )i
30
ac + bd
bc ad
(a + bi )
= 2
+ 2
i
2
(c + di )
c +d
c +d2
"
r = a2 + b2
K
4
0
!J.
*"
37
(a + bi ) + (c + di ) = (a + c) + (b + d )i
30
9
1
K
)
1
!
* .
= arctan
a
b
"
&
$%&
G
1
30
*)
42
8 4 !@
A
A
A
G <0
&
"
<0
$%&
30
)
"
* &
*)
'
"
9
+
30
<
"
)
"
"
'
* 7 !
!
*)
*
!
,
!
1
)
"
1 +
*
#
<
!
30
VERSO 1beta
&$-'4
$ $&
&, ,
.'@
&$ 2
,
< 4
43