diff --git a/03_Animal/python/animal.py b/03_Animal/python/animal.py index 077b93d7f..1c29f2faf 100644 --- a/03_Animal/python/animal.py +++ b/03_Animal/python/animal.py @@ -131,7 +131,7 @@ def main() -> None: # Main loop of game print_intro() while ( - keep_playing := parse_input( + parse_input( "Are you thinking of an animal? ", True, root ) == "y" diff --git a/07_Basketball/python/basketball.py b/07_Basketball/python/basketball.py index e3a598628..122185a13 100644 --- a/07_Basketball/python/basketball.py +++ b/07_Basketball/python/basketball.py @@ -139,7 +139,7 @@ def dartmouth_jump_shot(self) -> None: else: print("Shot is off target.") if self.defense / 6 * random.random() > 0.45: - print(f"Rebound to {self.opponent}" + "\n") + print(f"Rebound to {self.opponent}\n") self.opponent_ball() else: print("Dartmouth controls the rebound.") @@ -185,7 +185,7 @@ def dartmouth_non_jump_shot(self) -> None: if 7 / self.defense * random.random() > 0.925: print("Charging foul. Dartmouth loses the ball.\n") else: - print(f"Shot blocked. {self.opponent}" + "'s ball.\n") + print(f"Shot blocked. {self.opponent}'s ball.\n") else: self.foul_shots(1) self.opponent_ball() @@ -270,7 +270,7 @@ def opponent_jumpshot(self) -> None: or self.defense != 6 and random.random() <= 0.5 ): - print(f"Pass back to {self.opponent}" + " guard.\n") + print(f"Pass back to {self.opponent} guard.\n") self.opponent_ball() elif self.defense == 6 and random.random() > 0.75: print("Ball stolen. Easy lay up for Dartmouth.") @@ -310,14 +310,14 @@ def opponent_non_jumpshot(self) -> None: and random.random() <= 0.75 and random.random() <= 0.5 ): - print(f"Pass back to {self.opponent}" + " guard.\n") + print(f"Pass back to {self.opponent} guard.\n") self.opponent_ball() elif self.defense == 6 and random.random() > 0.75: print("Ball stolen. Easy lay up for Dartmouth.") self.add_points(1, 2) self.opponent_ball() else: - print(f"Pass back to {self.opponent}" + " guard\n") + print(f"Pass back to {self.opponent} guard\n") self.opponent_ball() else: print("Dartmouth controls the rebound.\n") diff --git a/17_Bullfight/python/bullfight.py b/17_Bullfight/python/bullfight.py index 32a6ac107..cfe3ed7ed 100644 --- a/17_Bullfight/python/bullfight.py +++ b/17_Bullfight/python/bullfight.py @@ -29,7 +29,7 @@ def determine_player_kills( print(f"THE {player_type}{plural_form} DID A {job_qualities[job_quality]} JOB.") if job_quality >= 4: if job_quality == 5: - if player_was_killed := random.choice([True, False]): + if random.choice([True, False]): print(f"ONE OF THE {player_type}{plural_form} WAS KILLED.") else: if player_type != "TOREAD": diff --git a/49_Hockey/python/hockey.py b/49_Hockey/python/hockey.py index c65d889e4..7b1e1ecf6 100644 --- a/49_Hockey/python/hockey.py +++ b/49_Hockey/python/hockey.py @@ -127,7 +127,7 @@ def print_header() -> None: def instructions() -> None: - if wants_it := ask_binary( + if ask_binary( "WOULD YOU LIKE THE INSTRUCTIONS? ", "ANSWER YES OR NO!!" ): print() @@ -229,7 +229,7 @@ def team2_action( z1 = 3 elif pass_value == 2: print("IT'S A ' 3 ON 2 '!\n") - print(f"ONLY {team_a.players[3]} AND {team_a.players[4]}" + " ARE BACK.\n") + print(f"ONLY {team_a.players[3]} AND {team_a.players[4]} ARE BACK.\n") print( team_b.players[player_index[j - 2]] + " GIVES OFF TO " @@ -374,7 +374,7 @@ def handle_hit( else: print(f"{team_b.name}: {team_b.score}\t{team_a.name}: {team_a.score}\n") team = team_a if controlling_team == 1 else team_b - print(f"GOAL SCORED BY: {team.players[goal_player]}" + "\n") + print(f"GOAL SCORED BY: {team.players[goal_player]}\n") if goal_assistant1 != 0: if goal_assistant2 != 0: print( @@ -402,16 +402,16 @@ def handle_miss( saving_player = randint(1, 7) if controlling_team == 1: if saving_player == 1: - print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}" + "\n") - print(f"CLEARED OUT BY {team_b.players[3]}" + "\n") + print(f"KICK SAVE AND A BEAUTY BY {team_b.players[5]}\n") + print(f"CLEARED OUT BY {team_b.players[3]}\n") remaining_time -= 1 return ("continue", remaining_time) if saving_player == 2: - print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}" + "\n") - print(f"AND {team_b.players[5]}" + " GOLFS IT INTO THE CROWD\n") + print(f"WHAT A SPECTACULAR GLOVE SAVE BY {team_b.players[5]}\n") + print(f"AND {team_b.players[5]} GOLFS IT INTO THE CROWD\n") return ("break", remaining_time) if saving_player == 3: - print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}" + "\n") + print(f"SKATE SAVE ON A LOW STEAMER BY {team_b.players[5]}\n") remaining_time -= 1 return ("continue", remaining_time) if saving_player == 4: @@ -447,20 +447,20 @@ def handle_miss( print("ON THE LOOSE PUCK!\n") return ("break", remaining_time) if saving_player == 3: - print(f"SKATE SAVE BY {team_a.players[5]}" + "\n") + print(f"SKATE SAVE BY {team_a.players[5]}\n") print(team_a.players[5] + " WHACKS THE LOOSE PUCK INTO THE STANDS\n") return ("break", remaining_time) if saving_player == 4: - print(f"STICK SAVE BY {team_a.players[5]}" + " AND HE CLEARS IT OUT HIMSELF\n") + print(f"STICK SAVE BY {team_a.players[5]} AND HE CLEARS IT OUT HIMSELF\n") remaining_time -= 1 return ("continue", remaining_time) if saving_player == 5: - print(f"KICKED OUT BY {team_a.players[5]}" + "\n") + print(f"KICKED OUT BY {team_a.players[5]}\n") print("AND IT REBOUNDS ALL THE WAY TO CENTER ICE\n") remaining_time -= 1 return ("continue", remaining_time) if saving_player == 6: - print(f"GLOVE SAVE {team_a.players[5]}" + " AND HE HANGS ON\n") + print(f"GLOVE SAVE {team_a.players[5]} AND HE HANGS ON\n") return ("break", remaining_time) return ("continue", remaining_time) diff --git a/59_Lunar_LEM_Rocket/python/lunar.py b/59_Lunar_LEM_Rocket/python/lunar.py index 228093e91..b65e0fa54 100644 --- a/59_Lunar_LEM_Rocket/python/lunar.py +++ b/59_Lunar_LEM_Rocket/python/lunar.py @@ -324,7 +324,7 @@ def run_simulation() -> None: return if capsule.velocity > 0 and new_state.velocity < 0: - if landed := handle_flyaway(sim_clock, capsule): + if handle_flyaway(sim_clock, capsule): process_final_tick(delta_t, sim_clock, capsule) return diff --git a/64_Nicomachus/python/nicomachus.py b/64_Nicomachus/python/nicomachus.py index e5d1c8253..1485d4a1c 100644 --- a/64_Nicomachus/python/nicomachus.py +++ b/64_Nicomachus/python/nicomachus.py @@ -43,7 +43,7 @@ def play_game() -> None: print(f"YOUR NUMBER WAS {d}, RIGHT?") - if response := get_yes_or_no(): + if get_yes_or_no(): print("HOW ABOUT THAT!!") else: print("I FEEL YOUR ARITHMETIC IS IN ERROR.") diff --git a/65_Nim/python/Traditional_NIM.py b/65_Nim/python/Traditional_NIM.py index ead90b2d0..655e5d85c 100644 --- a/65_Nim/python/Traditional_NIM.py +++ b/65_Nim/python/Traditional_NIM.py @@ -78,14 +78,14 @@ def main() -> None: # Start game loop input("\nPress Enter to start the Game:\n") - end = False + while True: game.print_pegs() # Players Move command = input("\nYOUR MOVE - Number of PILE, Number of Object? ") game.remove_pegs(command) - if end := game.check_for_win(): + if game.check_for_win(): print("\nPlayer Wins the Game, Congratulations!!") input("\nPress any key to exit") break @@ -96,7 +96,7 @@ def main() -> None: f"\nA.I MOVE - A.I Removed {ai_command[1]} pegs from Pile {ai_command[0]}" ) game.remove_pegs(f"{str(ai_command[0])},{str(ai_command[1])}") - if end := game.check_for_win(): + if game.check_for_win(): print("\nComputer Wins the Game, Better Luck Next Time\n") input("Press any key to exit") break diff --git a/69_Pizza/python/pizza.py b/69_Pizza/python/pizza.py index aa4a01e93..33bd60b6c 100644 --- a/69_Pizza/python/pizza.py +++ b/69_Pizza/python/pizza.py @@ -155,7 +155,7 @@ def main() -> None: player_name = print_instructions() - if more_directions := yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"): + if yes_no_prompt("DO YOU NEED MORE DIRECTIONS?"): print_more_directions(player_name) understand = yes_no_prompt("UNDERSTAND?") diff --git a/72_Queen/python/queen.py b/72_Queen/python/queen.py index 285174c49..327c43f6e 100755 --- a/72_Queen/python/queen.py +++ b/72_Queen/python/queen.py @@ -117,9 +117,9 @@ def num_to_loc(num: int) -> Tuple[int, int]: ) # These are the places that the computer will always try to move into. -COMPUTER_PREF_MOVES: Final[ - FrozenSet[Tuple[int, int]] -] = COMPUTER_SAFE_SPOTS | frozenset([WIN_LOC]) +COMPUTER_PREF_MOVES: Final[FrozenSet[Tuple[int, int]]] = ( + COMPUTER_SAFE_SPOTS | frozenset([WIN_LOC]) +) # These are the locations (not including the win location) from which either player can # force a win (but the computer will always choose one of the COMPUTER_PREF_MOVES). @@ -171,10 +171,10 @@ def get_move(current_loc: Optional[Tuple[int, int]]) -> Tuple[int, int]: "WHERE WOULD YOU LIKE TO START? " ) elif ( - (new_row == row and new_col < col) # move left - or (new_col == col and new_row > row) # move down - or (new_row - row == col - new_col) # move diag left and down - ) and (not FIX_BOARD_BUG or (new_col >= 0 and new_row < 8)): + (new_row == row and new_col < col) # move left + or (new_col == col and new_row > row) # move down + or (new_row - row == col - new_col) # move diag left and down + ) and (not FIX_BOARD_BUG or (new_col >= 0 and new_row < 8)): return new_row, new_col else: prompt = "Y O U C H E A T . . . TRY AGAIN? " diff --git a/89_Tic-Tac-Toe/python/TicTacToe_Hard.py b/89_Tic-Tac-Toe/python/TicTacToe_Hard.py index 8b3e50ab9..3a37cc6fe 100644 --- a/89_Tic-Tac-Toe/python/TicTacToe_Hard.py +++ b/89_Tic-Tac-Toe/python/TicTacToe_Hard.py @@ -171,7 +171,7 @@ def display(game: TicTacToe) -> None: if game.board[i][game.dim_sz - 1] == "blur": line1 = line1 + " \n" else: - line1 = f"{line1} {game.board[i][game.dim_sz - 1]}" + " \n" + line1 = f"{line1} {game.board[i][game.dim_sz - 1]} \n" print(line1, "\n\n")