This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| try: | |
| class SoccerGame: | |
| def __init__(self): | |
| self.team1_score = 0 | |
| self.team2_score = 0 | |
| self.current_team = 1 | |
| self.game_over = False | |
| def print_instructions(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| class FlightSimulator: | |
| def __init__(self): | |
| self.altitude = 0 | |
| self.speed = 0 | |
| self.fuel = 1000 | |
| self.distance = 0 | |
| self.destination = None | |
| self.is_flying = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| import random | |
| class ShootingGame: | |
| def __init__(self, player_name): | |
| self.player_name = player_name | |
| self.ammo = 6 | |
| self.targets = ["Bullseye", "Duck", "Deer", "Fox"] | |
| self.rounds = 5 | |
| self.score = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| class BasketballGame: | |
| def __init__(self, team1_name, team2_name): | |
| self.team1_name = team1_name | |
| self.team2_name = team2_name | |
| self.team1_score = 0 | |
| self.team2_score = 0 | |
| self.current_team = None | |
| self.current_quarter = 1 | |
| self.max_quarter = 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| class Gym: | |
| def __init__(self): | |
| self.members = [] | |
| self.equipment = {"treadmill": 5, "weight machine": 3, "elliptical": 2} | |
| def add_member(self, name): | |
| self.members.append(name) | |
| def remove_member(self, name): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| class Swimmer: | |
| def __init__(self, name): | |
| self.name = name | |
| self.distance = 0 | |
| def swim(self): | |
| swim_distance = random.randint(1, 4) | |
| self.distance += swim_distance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TennisGame: | |
| def __init__(self): | |
| self.player1_score = 0 | |
| self.player2_score = 0 | |
| self.player1_name = "Player 1" | |
| self.player2_name = "Player 2" | |
| self.current_server = self.player1_name | |
| def print_score(self): | |
| print(f"{self.player1_name}: {self.player1_score}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CheckerGame: | |
| def __init__(self): | |
| self.board_size = 8 | |
| self.board = [[None] * self.board_size for _ in range(self.board_size)] | |
| self.current_player = "Red" | |
| self.winner = None | |
| self.populate_board() | |
| def populate_board(self): | |
| for row in range(self.board_size): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| class SnakeAndLadder: | |
| def __init__(self): | |
| self.board_size = 10 | |
| self.board = list(range(self.board_size**2, 0, -1)) | |
| self.player_positions = {"Player 1": 0, "Player 2": 0} | |
| self.snake_positions = {16: 6, 47: 26, 49: 11, 56: 53, | |
| 62: 19, 64: 60, 87: 24, 93: 73, 95: 75, 98: 78} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import time | |
| try: | |
| class WhacAMole: | |
| def __init__(self, board_size=3): | |
| self.board_size = board_size | |
| self.board = [["O" for _ in range(board_size)] | |
| for _ in range(board_size)] | |
| self.score = 0 |