From 748d6d0ddfb3a823cd400895d61091947f9622b7 Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Thu, 16 Feb 2023 17:24:57 +0000 Subject: [PATCH 1/6] Definitely did lots of work today. Did NOT play games or scroll aimlessly on my phone. --- main.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 104be10..b6cb266 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,19 @@ class Vector2d: - pass \ No newline at end of file + def __init__(self,x,y): + self.x = x + self.y = y + + def __repr__(self): + return f"Vector2d(x={self.x},y = {self.y})" + + def __str__(self): + return f"{self.x}i + {self.y}j" + + def __abs__(self): + return (self.x**2 + self.y**2)**.5 + + def __neg__(self): + return f"Vector(-{self.x},-{self.y})" + + def __add__(self,other): + return f"Vector2d({int(self.x) + int(other.x)},{int(self.y) + int(other.y)})" \ No newline at end of file From b1684fa393ba53c84b4095ecd5510adef4246120 Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Thu, 16 Feb 2023 17:27:16 +0000 Subject: [PATCH 2/6] Definitely did lots of work today. Did NOT play games or scroll aimlessly on my phone. --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index b6cb266..dc3e213 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ def __str__(self): return f"{self.x}i + {self.y}j" def __abs__(self): - return (self.x**2 + self.y**2)**.5 + return str((int(self.x**2) + int(self.y**2))**.5) def __neg__(self): return f"Vector(-{self.x},-{self.y})" From 5b5f08938b7c0447ccfe378fedaf08bdd4cd7f88 Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Wed, 22 Feb 2023 20:00:59 +0000 Subject: [PATCH 3/6] Took me less than min --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index dc3e213..1693dc6 100644 --- a/main.py +++ b/main.py @@ -16,4 +16,9 @@ def __neg__(self): return f"Vector(-{self.x},-{self.y})" def __add__(self,other): - return f"Vector2d({int(self.x) + int(other.x)},{int(self.y) + int(other.y)})" \ No newline at end of file + return f"Vector2d({int(self.x) + int(other.x)},{int(self.y) + int(other.y)})" + + def __eq__(self,other): + return self.x == other.x and self.y == other.y + def __sub__(self,other): + return f"Vector2d({int(self.x) - int(other.x)},{int(self.y) - int(other.y)})" \ No newline at end of file From 2752c16b33101aac1440de92eafa3a085e9e0986 Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:41:28 +0000 Subject: [PATCH 4/6] The hardest classwork ever* --- instructions.md | 2 +- main.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/instructions.md b/instructions.md index e1ed429..6b0db7b 100644 --- a/instructions.md +++ b/instructions.md @@ -31,4 +31,4 @@ - 2/23/23 - - Write a method called `angle` that has `self` as its only parameter and returns the arctangent **in degrees** of the vector's `y` and `x` components. **NOTE:** You'll want to consult the documentation for [`math.atan2(y, x)`](https://docs.python.org/3/library/math.html#math.atan2) and [`math.degrees(x)`](https://docs.python.org/3/library/math.html#math.degrees) \ No newline at end of file + - Write a method called `angle` that has `self` as its only parameter and returns the arctangent **in degrees** of the vector's `y` and `x` components. **NOTE:** You'll want to consult the documentation for [`math.atan2(y, x)`](https://docs.python.org/3/library/math.html#math.atan2) and [`math.degrees(x)`](https://docs.python.org/3/library/math.html#math.degrees) diff --git a/main.py b/main.py index 1693dc6..fca73c7 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +import math + class Vector2d: def __init__(self,x,y): self.x = x @@ -16,9 +18,11 @@ def __neg__(self): return f"Vector(-{self.x},-{self.y})" def __add__(self,other): - return f"Vector2d({int(self.x) + int(other.x)},{int(self.y) + int(other.y)})" + return f"Vector2d({self.x + other.x},{self.y + other.y})" def __eq__(self,other): return self.x == other.x and self.y == other.y def __sub__(self,other): - return f"Vector2d({int(self.x) - int(other.x)},{int(self.y) - int(other.y)})" \ No newline at end of file + return f"Vector2d({self.x - other.x},{self.y - other.y})" + def angle(self): + return math.degrees(math.atan2(self.y,self.x)) \ No newline at end of file From 8d1f38699c79a621da65c414b38be404b0acf07c Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:52:52 +0000 Subject: [PATCH 5/6] Did my work eariler but unexpected everything got deleted --- main.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/main.py b/main.py index fca73c7..4518d64 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,20 @@ import math - class Vector2d: def __init__(self,x,y): self.x = x self.y = y def __repr__(self): - return f"Vector2d(x={self.x},y = {self.y})" - + return f"Vector2d(x={self.x}y={self.y})" def __str__(self): return f"{self.x}i + {self.y}j" - def __abs__(self): - return str((int(self.x**2) + int(self.y**2))**.5) - + return (self.x**2 + self.y**2)**.5 def __neg__(self): - return f"Vector(-{self.x},-{self.y})" - + return f"Vector2d(-{self.x},-{self.y})" def __add__(self,other): - return f"Vector2d({self.x + other.x},{self.y + other.y})" - - def __eq__(self,other): - return self.x == other.x and self.y == other.y - def __sub__(self,other): - return f"Vector2d({self.x - other.x},{self.y - other.y})" + return f"Vector2d{self.x + other.x},{self.y + other.y}" + def __eg__(self,other): + return self.x == other.x and self.y and other.y def angle(self): return math.degrees(math.atan2(self.y,self.x)) \ No newline at end of file From 94c88a677f3e61a3c0d3e2687cf5c875a923f86b Mon Sep 17 00:00:00 2001 From: 14197 <118582010+14197@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:57:04 +0000 Subject: [PATCH 6/6] Did everything in one line --- main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main.py b/main.py index 4518d64..6918e09 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,7 @@ import math class Vector2d: def __init__(self,x,y): - self.x = x - self.y = y - + self.x,self.y = x,y def __repr__(self): return f"Vector2d(x={self.x}y={self.y})" def __str__(self):