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 Animal: | |
| def __init__(self, name, species, hunger, happiness): | |
| self.name = name | |
| self.species = species | |
| self.hunger = hunger | |
| self.happiness = happiness |
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 Mastermind: | |
| def __init__(self, num_colors=6, num_positions=4, num_guesses=10): | |
| self.num_colors = num_colors | |
| self.num_positions = num_positions | |
| self.num_guesses = num_guesses | |
| self.secret_code = [random.randint( | |
| 1, num_colors) for i in range(num_positions)] |
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 | |
| # Define the symbols for the cards | |
| symbols = ["♠", "♣", "♥", "♦", "♤", "♧", "♡", "♢"] | |
| # Define the size of the board (even number) | |
| size = 4 | |
| # Generate a list of pairs of cards | |
| cards = [(symbol, i//2) for i in range(size*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
| matrix = [ [1, 2, 3], | |
| [4, 5, 6], | |
| [7, 8, 9] | |
| ] | |
| for row in matrix: | |
| for element in row: | |
| print(element, end=" ") | |
| print() |
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 Ship: | |
| def __init__(self, name, hull, firepower, accuracy): | |
| self.name = name | |
| self.hull = hull | |
| self.firepower = firepower | |
| self.accuracy = accuracy |
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 School: | |
| def __init__(self, name): | |
| self.name = name | |
| self.students = [] | |
| def add_student(self, student): | |
| self.students.append(student) | |
| def remove_student(self, student): | |
| if student in self.students: |
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 Train: | |
| def __init__(self, num_cars, speed): | |
| self.num_cars = num_cars | |
| self.speed = speed | |
| self.position = 0 | |
| def move(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
| import random | |
| try: | |
| class SumoWrestling: | |
| def __init__(self): | |
| self.player_position = 0 | |
| self.opponent_position = 10 | |
| self.ring_radius = 5 | |
| self.gameover = 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
| import time | |
| import random | |
| try: | |
| class RollerCoaster: | |
| def __init__(self): | |
| self.position = 0 | |
| self.speed = 0 | |
| self.duration = 60 | |
| self.gameover = 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
| import random | |
| class Player: | |
| def __init__(self): | |
| self.health = 3 | |
| self.coins = 0 | |
| self.position = 0 | |
| def move(self): |