|
@@ -1,6 +1,8 @@
|
|
|
# Наследование
|
|
|
|
|
|
# issubclass(sub, par)
|
|
|
+# 15.__class__ # узнать тип объекта
|
|
|
+# 15.__base__ # хранит ссылку на родителя
|
|
|
|
|
|
class Vehicle:
|
|
|
|
|
@@ -57,27 +59,26 @@ class Square(Rectangle):
|
|
|
pass
|
|
|
|
|
|
|
|
|
+class MyList(list):
|
|
|
+ def remove_all(self, value):
|
|
|
+ self[:] = [i for i in self if value != i]
|
|
|
+
|
|
|
+
|
|
|
+class NewInt(int):
|
|
|
+
|
|
|
+ def repeat(self, value=2):
|
|
|
+ return int(str(self)*value)
|
|
|
+
|
|
|
+ def to_bin(self):
|
|
|
+ return int(bin(self)[2:])
|
|
|
+
|
|
|
+
|
|
|
def main():
|
|
|
- shapes = [
|
|
|
- Polygon(), Triangle(), Ellipse(), Polygon(), Triangle(), Ellipse(), Polygon(), Square(), Polygon(), Circle(),
|
|
|
- Shape(), Polygon(), Triangle(), Circle(), Ellipse(), Shape(), Circle(), Rectangle(), Circle(), Circle(),
|
|
|
- Square(), Square(), Circle(), Rectangle(), Rectangle(), Polygon(), Polygon(), Polygon(), Square(), Square(),
|
|
|
- Rectangle(), Square(), Rectangle(), Polygon(), Circle(), Triangle(), Rectangle(), Shape(), Rectangle(),
|
|
|
- Polygon(), Polygon(), Ellipse(), Square(), Circle(), Shape(), Polygon(), Ellipse(), Triangle(), Square(),
|
|
|
- Polygon(), Triangle(), Circle(), Rectangle(), Rectangle(), Ellipse(), Triangle(), Rectangle(), Polygon(),
|
|
|
- Shape(), Circle(), Rectangle(), Polygon(), Triangle(), Circle(), Polygon(), Rectangle(), Polygon(), Square(),
|
|
|
- Triangle(), Circle(), Ellipse(), Circle(), Shape(), Circle(), Triangle(), Ellipse(), Square(), Circle(),
|
|
|
- Triangle(), Polygon(), Square(), Polygon(), Circle(), Ellipse(), Polygon(), Shape(), Triangle(), Rectangle(),
|
|
|
- Circle(), Square(), Triangle(), Triangle(), Ellipse(), Square(), Circle(), Rectangle(), Ellipse(), Shape(),
|
|
|
- Triangle(), Ellipse(), Circle(), Shape(), Polygon(), Polygon(), Ellipse(), Rectangle(), Square(), Shape(),
|
|
|
- Circle(), Triangle(), Circle(), Circle(), Circle(), Triangle(), Ellipse(), Polygon(), Circle(), Ellipse(),
|
|
|
- Rectangle(), Circle(), Shape(), Polygon(), Polygon(), Triangle(), Rectangle(), Polygon(), Shape(), Circle(),
|
|
|
- Shape(), Circle(), Triangle(), Ellipse(), Square(), Circle(), Triangle(), Ellipse(), Square(), Circle(),
|
|
|
-]
|
|
|
-
|
|
|
- ret = [i for i in shapes if isinstance(i, (Polygon))]
|
|
|
- print(len(ret))
|
|
|
-# 29 33 79
|
|
|
+ i = NewInt(34)
|
|
|
+ print(i.repeat(3))
|
|
|
+ print(i.to_bin())
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|