python_11.pdf
(
77 KB
)
Pobierz
75065206 UNPDF
Kurs języka Python
Wykład 11.
●
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:
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