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:
kefirowocowy
Inne pliki z tego folderu:
python_1.pdf
(52 KB)
python_2.pdf
(470 KB)
python_12.pdf
(65 KB)
python_10.pdf
(63 KB)
python_11.pdf
(77 KB)
Inne foldery tego chomika:
Zgłoś jeśli
naruszono regulamin