python_12.pdf
(
65 KB
)
Pobierz
Kurs języka Python
Wykład 12.
●
Atrybuty
●
Iteratory
●
Introspekcje (refleksje)
●
Dynamiczne generowanie kodu
Funkcje i operatory wbudowane
●
cmp(x,y)
●
d[i]
●
len(collection)
●
d[i] = v
●
str(obj)
●
del v[i]
●
<
●
>
●
==
●
+, -, * , /
●
....
Zadanie
Implementacja klasy wektorów wraz z
operatorami +, -, ...
Implementacja
class
Vector:
def
__init__(
self
, lista):
self
.value = lista
dodawanie
def
__add__(
self
, arg):
if
self
.__class__ <> arg.__class__
or
\
len(
self
.value) <> len(
arg
.value):
return
None
res = \
Vector( [x + y
for
x,y
in
zip(
self
.value,arg.value) ])
return
res
Plik z chomika:
repulsive
Inne pliki z tego folderu:
Wrox.Beginning.Python.Jul.2005.eBook-LinG.(osloskop.net).pdf
(15412 KB)
Rapid Web Applications With TurboGears - Using Python To Create Ajax-Powered Sites (2006).chm
(6367 KB)
spis_stresci.pdf
(126 KB)
roz_V.pdf
(157 KB)
roz_null.pdf
(304 KB)
Inne foldery tego chomika:
paczka nowa
Zgłoś jeśli
naruszono regulamin