diff --git a/1_beginner/chapter3/examples/math_operators.py b/1_beginner/chapter3/examples/math_operators.py index 00648a58..8c54a408 100644 --- a/1_beginner/chapter3/examples/math_operators.py +++ b/1_beginner/chapter3/examples/math_operators.py @@ -29,4 +29,4 @@ # Exponent x = 2 y = 3 -print(x ** y) # prints 8 +print(x**y) # prints 8 diff --git a/1_beginner/chapter3/solutions/circle.py b/1_beginner/chapter3/solutions/circle.py index 3afe613f..78463e52 100644 --- a/1_beginner/chapter3/solutions/circle.py +++ b/1_beginner/chapter3/solutions/circle.py @@ -10,7 +10,7 @@ radius = float(input("Enter a radius: ")) # Calculate the area and circumference -area = PI * radius ** 2 +area = PI * radius**2 circumference = 2 * PI * radius # Print the result diff --git a/1_beginner/chapter3/solutions/cylinder_volume.py b/1_beginner/chapter3/solutions/cylinder_volume.py index 94897dfd..07494915 100644 --- a/1_beginner/chapter3/solutions/cylinder_volume.py +++ b/1_beginner/chapter3/solutions/cylinder_volume.py @@ -6,5 +6,5 @@ PI = 3.14 height = float(input("Height of cylinder: ")) radius = float(input("Radius of cylinder: ")) -volume = PI * radius ** 2 * height +volume = PI * radius**2 * height print("The volume of the cylinder is", volume) diff --git a/1_beginner/chapter4/solutions/square.py b/1_beginner/chapter4/solutions/square.py index 2dbde5cf..678cae8b 100644 --- a/1_beginner/chapter4/solutions/square.py +++ b/1_beginner/chapter4/solutions/square.py @@ -9,7 +9,7 @@ if number % 2 == 0: # if number is even, print its square - print(number ** 2) + print(number**2) else: # otherwise, print the number itself print(number) diff --git a/2_intermediate/chapter13/examples/vector2.py b/2_intermediate/chapter13/examples/vector2.py index 3f75af81..224ccd01 100644 --- a/2_intermediate/chapter13/examples/vector2.py +++ b/2_intermediate/chapter13/examples/vector2.py @@ -24,7 +24,7 @@ def __str__(self): """ def __pow__(self, power): - return Vector([i ** power for i in self.vals]) + return Vector([i**power for i in self.vals]) """ Addition: adds each element to corresponding element in other vector @@ -53,7 +53,7 @@ def __sub__(self, vec): vec = Vector([2, 3, 2]) otherVec = Vector([3, 4, 5]) print(str(vec)) # [2, 3, 2] -print(vec ** 2) # [4, 9, 4] +print(vec**2) # [4, 9, 4] print(vec - otherVec) # [-1, -1, -3] print(vec + otherVec) # [5, 7, 7] print(vec * 5) # [10, 15, 10] diff --git a/2_intermediate/chapter13/examples/vector3.py b/2_intermediate/chapter13/examples/vector3.py index fe70f498..25307216 100644 --- a/2_intermediate/chapter13/examples/vector3.py +++ b/2_intermediate/chapter13/examples/vector3.py @@ -20,11 +20,11 @@ def __str__(self): return str(self.vals) def __pow__(self, power): - return Vector([i ** power for i in self.vals]) + return Vector([i**power for i in self.vals]) # Calculates Euclidean norm def norm(self): - return sum((self ** 2).vals) ** 0.5 + return sum((self**2).vals) ** 0.5 # __lt__: implements the less than operator (<) def __lt__(self, other): diff --git a/3_advanced/chapter14/solutions/odd_squares.py b/3_advanced/chapter14/solutions/odd_squares.py index 1e385094..4a4dfd74 100644 --- a/3_advanced/chapter14/solutions/odd_squares.py +++ b/3_advanced/chapter14/solutions/odd_squares.py @@ -10,4 +10,4 @@ ex_list[idx] = int(ex_list[idx]) # write your code below -odds_quares = [n ** 2 for n in list if n % 2 == 1] +odds_quares = [n**2 for n in list if n % 2 == 1] diff --git a/games/chapter4/examples/OOP_game.py b/games/chapter4/examples/OOP_game.py index 1114c0df..ab3bf7c7 100644 --- a/games/chapter4/examples/OOP_game.py +++ b/games/chapter4/examples/OOP_game.py @@ -375,7 +375,7 @@ def check_events(self, event): mouse_pos = pygame.mouse.get_pos() h = mouse_pos[1] - bul.rect.center[1] w = mouse_pos[0] - bul.rect.center[0] - hyp = math.sqrt(h ** 2 + w ** 2) + hyp = math.sqrt(h**2 + w**2) vertical_speed = ( BULLETSPEED[1] * (h / hyp) if hyp != 0 else BULLETSPEED[1] * h ) diff --git a/games/chapter5/practice/sound_tanks.py b/games/chapter5/practice/sound_tanks.py index f9fb204a..e33e7e6a 100644 --- a/games/chapter5/practice/sound_tanks.py +++ b/games/chapter5/practice/sound_tanks.py @@ -370,7 +370,7 @@ def check_events(self, event): mouse_pos = pygame.mouse.get_pos() h = mouse_pos[1] - bul.rect.center[1] w = mouse_pos[0] - bul.rect.center[0] - hyp = math.sqrt(h ** 2 + w ** 2) + hyp = math.sqrt(h**2 + w**2) vertical_speed = ( BULLETSPEED[1] * (h / hyp) if hyp != 0 else BULLETSPEED[1] * h ) diff --git a/games/chapter5/solutions/sound_tanks.py b/games/chapter5/solutions/sound_tanks.py index 014044f2..051e181c 100644 --- a/games/chapter5/solutions/sound_tanks.py +++ b/games/chapter5/solutions/sound_tanks.py @@ -378,7 +378,7 @@ def check_events(self, event): mouse_pos = pygame.mouse.get_pos() h = mouse_pos[1] - bul.rect.center[1] w = mouse_pos[0] - bul.rect.center[0] - hyp = math.sqrt(h ** 2 + w ** 2) + hyp = math.sqrt(h**2 + w**2) vertical_speed = ( BULLETSPEED[1] * (h / hyp) if hyp != 0 else BULLETSPEED[1] * h )