Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vector2D:
- def __init__(self,x,y):
- self.x = x
- self.y = y
- def __add__(v1,v2):
- suma = v1.x + v2.x
- suma2 = v1.y + v2.y
- return Vector2D(suma,suma2)
- def __str__(self):
- return '(%s,%s)' % (self.x,self.y)
- def __sub__(v1,v2):
- resta = v1.x - v2.x
- resta2 = v1.y - v2.y
- return Vector2D(resta,resta2)
- def productoesc(v1,v2):
- mult = v1.x + v2.x
- mult1 = v1.y + v2.y
- mult2 = mult * mult1
- return mult2
- v1 = Vector2D(3,10)
- v2 = Vector2D(6,8)
- print v1+v2
- print v1-v2
- print productoesc(v1,v2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement