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:
kizia100
Inne pliki z tego folderu:
python_13.pdf
(36 KB)
python_6.pdf
(88 KB)
python_5.pdf
(64 KB)
python_8.pdf
(43 KB)
python_4.pdf
(41 KB)
Inne foldery tego chomika:
Pliki dostępne do 01.06.2025
Pliki dostępne do 08.07.2024
Pliki dostępne do 19.01.2025
Pliki dostępne do 21.01.2024
✂ SZYCIE ✂
Zgłoś jeśli
naruszono regulamin