human
I am working on the file "LectureProgrammingParadigms/Lecture Programming Paradigms.ipynb".
The first task is:
Wait, there's more!
We found a way to map real objects in source code.
But so far we have ignored a possible hierarchical relation among objects.
For example: animal -> mammal -> cat
It looks like in such a hierarchy some properties are shared and some are not.
It's not too far-fetched to assume that this sort of hierarchies makes also sense in programming.
It's called inheritance and it works in Python like this:
Can you write Python code for it?
assistant
#Here is the Python code you requested.

from math import cos, sin, sqrt

class MyVector():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        
    def get_length(self):
        return sqrt(self.x * self.x + self.y * self.y)
    
    def scale_vector(self, a):
        self.x *= a
        self.y *= a
        
    def add_vector(self, vector):
        self.x += vector.x
        self.y += vector.y
        
    def __add__(self, other):
        x = self.x + other.x
        y = self.y + other.y
        return MyVector(x, y)
    
    def get_r(self):
        return self.get_length()

class MyPolarVector(MyVector):
    def __init__(self, r, phi):
        self.r = r
        MyVector.__init__(self, r * cos(phi), r * sin(phi))
    
    def get_length(self):
        print "inside MyPolarVector"
        return self.r
    
    def get_r(self):
        return self.r

v1 = MyVector(10, 20)
v2 = MyPolarVector(12, 2.7)

print (v1 + v2).get_r()

print v1.get_length()
print v2.get_length()
print (v1 + v2).get_length()