python_4.pdf
(
41 KB
)
Pobierz
75064184 UNPDF
Kurs języka Python
Wykład 4.
Plan:
–
Obiekty
–
Wyjątki
–
Zmienne
Definicja klasy
class
Figura:
''''''Pierwsza klasa''''''
def
__init__(
self
, x, y):
self
.x = x
self
.y = y
2
Definicja metody
class
Figura:
...
def
info(
self
):
print
self
.x,
self
.y
def
zmien(
self
, x, y):
self
.x = x
self
.y = y
3
Wywołanie metody
o = Figura()
o.info()
o.zmien(2,3)
o.info()
4
Dziedziczenie
class
Okrag(Figura):
''''''Okrag''''''
def
__init__(
self
):
self
.x,
self
.y,
self
.r = 0, 0, 1
def
info(
self
):
print
'x = %i, y = %i, r = %i'
, (
self
.x,
self
.y,
self
.r)
5
Plik z chomika:
xyzgeo
Inne pliki z tego folderu:
Python Algorithms.pdf
(2320 KB)
Python and AWS Cookbook.pdf
(3786 KB)
Python and HDF5.pdf
(7112 KB)
Python and XML.pdf
(4029 KB)
Python Cookbook, 2nd Edition.pdf
(4752 KB)
Inne foldery tego chomika:
bipython
PYTHON
python (acabose)
tutoriale
wyklady
Zgłoś jeśli
naruszono regulamin