In [34]:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
url_svg = 'http://clipartist.net/social/clipartist.net/B/base_tux_g_v_linux.svg'
import matplotlib.pyplot as plt
from IPython.display import SVG, display
# testing svg inside jupyter next one does not support
#display(SVG(url=url_svg))
from IPython.core.display import HTML
HTML('<img src="' + url_svg + '" width=100 height=20/>')
Out[34]:
In [5]:
float(i)
Out[5]:
In [4]:
type(x)
Out[4]:
In [6]:
class Point(object):
"""
A simple 2D cartesian Point with x and y coordinates
"""
def __init__(self,x=0.0,y=0.0):
self.x = float(x)
self.y = float(y)
def __repr__(self):
return ("x,y = {x},{y}".format(x=self.x,y=self.y))
def move(self,newx,newy):
"""
This method moves the point to newx,newy position
"""
self.x = float(newx)
self.y = float(newy)
def moverel(self,dx,dy):
"""
This method moves the point ny dx,dy relative to its current position
"""
self.x += float(dx)
self.y += float(dy)
In [21]:
P0 = Point()
P1 = Point(1,2)
P2 = Point(3,5)
print("P0 {p0}, P1 {p1} and P2 {p2}".format(p0=P0,p1=P1,p2=P2))
In [22]:
P1.move(4,4)
P2.moverel(1,-1)
print("P1 {p1} and P2 {p2}".format(p1=P1,p2=P2))
P1==P2
Out[22]:
In [9]:
class NamedPoint(Point):
def __init__(self,name,x,y):
Point.__init__(self,x,y)
self.name = name
def __repr__(self):
return ("{name} : ".format(name=self.name) + Point.__repr__(self))
In [10]:
P3 = NamedPoint('P3',3,3)
print P3
In [55]:
P3.move(1,1)
print P3
In [56]:
type(P3)
Out[56]:
In [16]:
P2==P1
Out[16]:
In [12]:
P4
Out[12]:
In [13]:
type(P4)
Out[13]:
In [ ]: