diff --git a/In Class Lab Activities/Array backed grids.py b/In Class Lab Activities/Array backed grids.py new file mode 100644 index 000000000..f82b1de8f --- /dev/null +++ b/In Class Lab Activities/Array backed grids.py @@ -0,0 +1,72 @@ +import arcade + +width = 20 +height = 20 +margin = 5 +ROW_COUNT = 10 +COLUMN_COUNT = 10 +SCREEN_WIDTH = width * COLUMN_COUNT + margin * (COLUMN_COUNT + 1) +SCREEN_HEIGHT = width * ROW_COUNT + margin * (ROW_COUNT + 1) + + +class MyGame(arcade.Window): + """ + Main application class. + """ + + def __init__(self, width, height): + super().__init__(width, height) + # --- Create grid of numbers + # Create an empty list + self.grid = [] + # Loop for each row + for row in range(ROW_COUNT): + # For each row, create a list that will + # represent an entire row + self.grid.append([]) + # Loop for each column + for column in range(COLUMN_COUNT): + # Add a the number zero to the current row + self.grid[row].append(0) + + arcade.set_background_color(arcade.color.BLACK) + + def on_draw(self): + """ + Render the screen. + """ + + arcade.start_render() + for row in range(ROW_COUNT): + for column in range(COLUMN_COUNT): + color = arcade.color.WHITE + if self.grid[row][column] == 1: + color = arcade.color.GREEN + x = (margin + width) * column + margin + width // 2 + y = (margin + width) * row + margin + width // 2 + arcade.draw_rectangle_filled(x, y, width, height, color) + + def on_mouse_press(self, x, y, button, key_modifiers): + """ + Called when the user presses a mouse button. + """ + column = x // (width + margin) + row = y // (height + margin) + + print(f"Click coordinates: ( {x}, {y}. Grid Coordinates: ({row}, {column})") + + if row < ROW_COUNT and column < COLUMN_COUNT: + + if self.grid[row][column] == 0: + self.grid[row][column] = 1 + else: + self.grid[row][column] = 0 + + +def main(): + window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT) + arcade.run() + + +if __name__ == "__main__": + main() diff --git a/In Class Lab Activities/Loops/for_loops.py b/In Class Lab Activities/Loops/for_loops.py new file mode 100644 index 000000000..b1e219f68 --- /dev/null +++ b/In Class Lab Activities/Loops/for_loops.py @@ -0,0 +1,88 @@ +# Review questions chapter 11 +"""for i in range(10): + print("Hi!") + + + +for i in range (5): + print("Hello") +print("There") + + + +for i in range (5): + print("Hello") + print("There") +# General Kenobi + + + +for i in range (10): + print(i) + + + +for i in range (1,11): + print(i) + + +for i in range (10): + print(i+1) + + +for i in range (2, 12, 2): + print(i) + + +for i in range (5): + print((i+1)*2) + + +for i in range (10, 0, -1): + print(i) + + +for i in range(3): + print("a") + for j in range(3): + print("b") + + + +a = 0 +for i in range(10): + a = a + 1 + for j in range(10): + a = a + 1 +print(a) + + +total = 0 +for i in range(1, 101): + total = total + i + print(total) + + +i=0 +while i < 10: + print(i) + i=i+1 + + +i = 1 +while i <= 2**32: + print(i) + i *= 2""" + + +keep_going="yes" + +while keep_going="yes" + a = input("would you like to try again?") + if a = "no" + keep_going=a + else + + + + diff --git a/In Class Lab Activities/class_methods.py b/In Class Lab Activities/class_methods.py new file mode 100644 index 000000000..5e5406cb8 --- /dev/null +++ b/In Class Lab Activities/class_methods.py @@ -0,0 +1,54 @@ +"""class Cat: + def __init__(self): + self.color = "" + self.name = "" + self.weight = 0 + + def meow(self): + print("Meow!") + + +my_cat = Cat() +my_cat.color = "Brown" +my_cat.name = "Tank" +my_cat.weight = 10 + +print("My cats name is", my_cat.name) +my_cat.meow() + +class Monster: + def __init__(self): + self.name = "" + self.health = 0 + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + + +monster1 = Monster() +monster1.name = "Omnom" +monster1.health = 30 + +print("The monster is", monster1.name) +monster1.decrease_health(31) + +class Monster: + def __init__(self, health, name): + self.name = name + self.health = health + + def decrease_health(self, amount): + self.health -= amount + if 0 >= self.health: + print("The monster is dead.") + +class Star: + def __init__(self): + print("A star is born!") + +star1 = Star() +star2 = Star() +star3 = Star()""" + diff --git a/Lab 01 - First Program/lab_01.py b/Lab 01 - First Program/lab_01.py index e69de29bb..ee439b1bd 100644 --- a/Lab 01 - First Program/lab_01.py +++ b/Lab 01 - First Program/lab_01.py @@ -0,0 +1,8 @@ +print("Hold your ground! Hold Your Ground!. \nSons of Gondor, of Rohan, my brothers.") +print("""A day may come when the courage of men fails, +when we forsake and break all bonds of fellowship, but it is not this day. +An hour of wolves and shattered shields, +when the age of men comes crashing down, +but it is not this day!""") +print("This day we fight!") +print("By all that you hold dear on this good Earth, \nI bid you stand, \nMen of the West!") diff --git a/Lab 02 - Draw a Picture/lab_02.py b/Lab 02 - Draw a Picture/lab_02.py index e69de29bb..a1347145d 100644 --- a/Lab 02 - Draw a Picture/lab_02.py +++ b/Lab 02 - Draw a Picture/lab_02.py @@ -0,0 +1,59 @@ + +import arcade + + +arcade.open_window(800, 600, ) + +# Set the background color +arcade.set_background_color(arcade.color.BLUE_GRAY) + +# Get ready to draw +arcade.start_render() + +# Draw the snowy ground +arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) + +# --- Draw Clouds --- + +arcade.draw_ellipse_filled(200, 350, 50, 50, arcade.color.SNOW) + +arcade.draw_ellipse_filled(500, 270, 200, 110, arcade.color.SNOW) + +arcade.draw_ellipse_filled(10, 250, 110, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(670, 280, 90, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(400, 300, 70, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(300, 400, 150, 70, arcade.color.SNOW) + +arcade.draw_ellipse_filled(750, 500, 150, 150, arcade.color.SNOW) + +arcade.draw_ellipse_filled(500, 500, 50, 50, arcade.color.SNOW) + +# --- Draw Snowman --- + +# Bottom circle +arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) +arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 110, 10, arcade.color.BLACK_BEAN) + +# Middle Circle +arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) +arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) + +# Top Circle +arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) +arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) +arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) +arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) +arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) +arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) +# --- Finish drawing --- +arcade.finish_render() + +# Keep the window up until someone closes it. +arcade.run() diff --git a/Lab 03 - Draw Using Functions/lab_03.py b/Lab 03 - Draw Using Functions/lab_03.py index e69de29bb..91e926d47 100644 --- a/Lab 03 - Draw Using Functions/lab_03.py +++ b/Lab 03 - Draw Using Functions/lab_03.py @@ -0,0 +1,77 @@ +import arcade + +SCREEN_WIDTH = 800 +SCREEN_HEIGHT = 600 + +def setupdrawing(): + arcade.open_window(800, 600, ) + + # Set the background color + arcade.set_background_color(arcade.color.BLUE_GRAY) + + # Get ready to draw + arcade.start_render() + + # Draw the ground +def drawground(): + arcade.draw_rectangle_filled(0, 800, 200, 0, arcade.color.WHITE) + +def drawcloud(): + # --- Draw Clouds --- + + arcade.draw_ellipse_filled(200, 350, 50, 50, arcade.color.SNOW) + + arcade.draw_ellipse_filled(500, 270, 200, 110, arcade.color.SNOW) + + arcade.draw_ellipse_filled(10, 250, 110, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(670, 280, 90, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(400, 300, 70, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(300, 400, 150, 70, arcade.color.SNOW) + + arcade.draw_ellipse_filled(750, 500, 150, 150, arcade.color.SNOW) + + arcade.draw_ellipse_filled(500, 500, 50, 50, arcade.color.SNOW) + +def snowmantop(): + # Top Circle + arcade.draw_circle_filled(490, 230, 25, arcade.color.BLACK) + arcade.draw_circle_filled(490, 230, 15, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 230, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 225, 3, arcade.color.ORANGE) + arcade.draw_circle_filled(500, 230, 3, arcade.color.BLACK_BEAN) + arcade.draw_circle_filled(480, 230, 3, arcade.color.BLACK_BEAN) + +def snowmanmiddle(): + # Middle Circle + arcade.draw_circle_filled(490, 180, 30, arcade.color.BLACK) + arcade.draw_circle_filled(490, 180, 25, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 180, 18, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 180, 5, arcade.color.BLACK_BEAN) + +def snowmanbottom(): + # Bottom circle + arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) + arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) + arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) + arcade.draw_circle_filled(490, 110, 10, arcade.color.BLACK_BEAN) + + + +def main(): + setupdrawing() + drawground() + drawcloud() + snowmantop() + snowmanbottom() + snowmanmiddle() + + # --- Finish drawing --- + arcade.finish_render() + arcade.run() + + +# Call the main function to get the program started. +main() diff --git a/Lab 04 - Camel/lab_04.py b/Lab 04 - Camel/lab_04.py index e69de29bb..94d30b21e 100644 --- a/Lab 04 - Camel/lab_04.py +++ b/Lab 04 - Camel/lab_04.py @@ -0,0 +1,123 @@ +import random + +# Game Variables +thirst = 0 +camel = 0 +natives = -20 +canteen = 3 +player = 0 + + +# Game Functions +def find_oasis(): + global thirst, camel, canteen + for i in range(1): + if random.randrange(20) == 19: + print("You have found an oasis! You refill your canteen and are able to rest alongside your camel") + thirst = 0 + camel = 0 + canteen = 3 + + +def move_natives(min_val, max_val): + global natives + natives += random.randint(min_val, max_val) + + +def rest_for_the_night(): + global camel + print("You've stopped for the night. Your camel lays down by your fire and is fully rested.") + camel = 0 + move_natives(7, 14) + + +def move_player(min_val, max_val): + global player + random_val = random.randint(min_val, max_val) + player += random_val + + +def go_full_speed(): + global thirst, camel + move_player(10, 20) + thirst += 1 + camel += random.randint(1, 3) + move_natives(7, 14) + print(f"You have traveled {player} miles.") + find_oasis() + + +def go_moderate_speed(): + global thirst, camel + move_player(5, 12) + thirst += 1 + camel += 1 + move_natives(7, 14) + print(f"You have traveled {player} miles.") + find_oasis() + + +def drink_from_canteen(): + global canteen, thirst + if canteen > 0: + canteen -= 1 + thirst = 0 + else: + print("Oh No! Your canteen is empty!") + + +# Main Game +def main(): + print("Welcome to Camel!") + print("You have stolen a camel to make your way across the great Mobi desert.") + print("The natives want their camel back and are chasing you down!") + print("Survive your desert trek and out run the natives.") + done = False + while not done: + print("A. Drink from your canteen.") + print("B. Ahead moderate speed") + print("C. Ahead full speed.") + print("D. Stop for the night.") + print("E. Status check.") + print("Q. Quit.") + choice = input("What is your choice? ") + if choice.upper() == 'Q': + done = True + print("Thanks for playing!") + elif choice.upper() == 'E': + print(f"Miles traveled: {player}") + print(f"Drinks remaining: {canteen}") + print(f"The natives are {player - natives} miles away.") + elif choice.upper() == 'D': + rest_for_the_night() + elif choice.upper() == 'C': + go_full_speed() + elif choice.upper() == 'B': + go_moderate_speed() + elif choice.upper() == 'A': + drink_from_canteen() + # Game Check + if thirst >= 6: + done = True + print("You've died of thirst!") + elif thirst > 4: + print("You are thirsty.") + + if camel >= 8: + done = True + print("Your camel is dead.") + elif camel >= 5: + print("Your camel is getting tired.") + + if natives >= player: + done = True + print("The natives have caught you!") + elif (player - natives) < 15: + print("The natives are getting close!") + + if player >= 200: + done = True + print("You've made it across the desert! You won!") + + +main() diff --git a/Lab 05 - Loopy Lab/lab_05.py b/Lab 05 - Loopy Lab/lab_05.py index e69de29bb..b70f0a262 100644 --- a/Lab 05 - Loopy Lab/lab_05.py +++ b/Lab 05 - Loopy Lab/lab_05.py @@ -0,0 +1,122 @@ +import arcade + + +def draw_section_outlines(): + # Draw squares on bottom + arcade.draw_rectangle_outline(150, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(450, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(750, 150, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(1050, 150, 300, 300, arcade.color.BLACK) + + # Draw squares on top + arcade.draw_rectangle_outline(150, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(450, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(750, 450, 300, 300, arcade.color.BLACK) + arcade.draw_rectangle_outline(1050, 450, 300, 300, arcade.color.BLACK) + + +def draw_section_1(): + for row in range(30): + for column in range(30): + x = column * 10 + 5 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def draw_section_2(): + # Below, replace "pass" with your code for the loop. + # Use the modulus operator and an if statement to select the color + # Don't loop from 30 to 60 to shift everything over, just add 300 to x. + for row in range(30): + for column in range(30): + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + if column % 2 == 0: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + elif column % 2 == 1: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.BLACK) + + +def draw_section_3(): + # Use the modulus operator and an if/else statement to select the color. + # Don't use multiple 'if' statements. + for row in range(30): + for column in range(30): + x = column * 10 + 5 + 600 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 # Instead of zero, calculate the proper y location using 'row' + if row % 2 == 0: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + elif row % 2 == 1: + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.BLACK) + + +def draw_section_4(): + # Use the modulus operator and just one 'if' statement to select the color. + for row in range(30): + for column in range(30): + color = arcade.color.BLACK + x = column * 10 + 5 + 900 + y = row * 10 + 5 + if row % 2 == 0 and column % 2 == 0: + color = arcade.color.WHITE + arcade.draw_rectangle_filled(x, y, 5, 5, color) + + +def draw_section_5(): + for column in range(30): + for row in range(column + 1): + x = column * 10 + 5 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def draw_section_6(): + for row in range(30): + for column in range(30 - row): + x = column * 10 + 5 + 300 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def draw_section_7(): + for row in range(30): + for column in range(row + 1): + x = column * 10 + 5 + 600 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def draw_section_8(): + for row in range(30): + for column in range(row + 1): + x = 290 - column * 10 + 5 + 900 # Instead of zero, calculate the proper x location using 'column' + y = row * 10 + 5 + 300 # Instead of zero, calculate the proper y location using 'row' + arcade.draw_rectangle_filled(x, y, 5, 5, arcade.color.WHITE) + + +def main(): + # Create a window + arcade.open_window(1200, 600, "Lab 05 - Loopy Lab") + arcade.set_background_color(arcade.color.AIR_FORCE_BLUE) + + arcade.start_render() + + # Draw the outlines for the sections + draw_section_outlines() + + # Draw the sections + draw_section_1() + draw_section_2() + draw_section_3() + draw_section_4() + draw_section_5() + draw_section_6() + draw_section_7() + draw_section_8() + + arcade.finish_render() + + arcade.run() + + +main() diff --git a/Lab 06 - Text Adventure/lab_06.py b/Lab 06 - Text Adventure/lab_06.py index e69de29bb..61019076b 100644 --- a/Lab 06 - Text Adventure/lab_06.py +++ b/Lab 06 - Text Adventure/lab_06.py @@ -0,0 +1,16 @@ +class Room: + """ This is a class that defines Rooms.""" + def __init__(self): + """ Set up Room attributes. """ + self.description = "" + self.north = 0 + self.south = 0 + self.east = 0 + self.west = 0 + + +def main(): + + """Main program function.""" + my_list = [] + room = Room() \ No newline at end of file diff --git a/Lab 10 - Spell Check/lab_10.py b/Lab 10 - Spell Check/lab_10.py index e69de29bb..aadef910e 100644 --- a/Lab 10 - Spell Check/lab_10.py +++ b/Lab 10 - Spell Check/lab_10.py @@ -0,0 +1,89 @@ +import re + + +# This function takes in a line of text and returns +# a list of words in the line. +def split_line(line): + return re.findall('[A-Za-z]+(?:\'[A-Za-z]+)?', line) + + +def main(): + """ Read in lines from a file """ + + # Open the file for reading, and store a pointer to it in the new + # variable "file" + my_file = open("dictionary.txt") + + # Create an empty list to store our names + dictionary_list = [] + + # Loop through each line in the file like a list + for line in my_file: + # Remove any line feed, carriage returns or spaces at the end of the line + line = line.strip() + + # Add the name to the list + dictionary_list.append(line) + + my_file.close() + + my_file = open("AliceInWonderLand200.txt") + print("---Linear Search---") + for line in my_file: + word_list = split_line(line) + for word in word_list: + # --- Linear search + key = word.upper() + + # Start at the beginning of the list + current_list_position = 0 + + # Loop until you reach the end of the list, or the value at the + # current position is equal to the key + while current_list_position < len(dictionary_list) and dictionary_list[current_list_position] != key: + # Advance to the next item in the list + current_list_position += 1 + + line_number = current_list_position + + if current_list_position < len(dictionary_list): + print(end="") + else: + print("Possible misspelled word", key, "on line", line_number) + print("---Binary Search---") + my_file.close() + + my_file = open("AliceInWonderLand200.txt") + for line in my_file: + word_list = split_line(line) + for word in word_list: + # --- Binary search + key = word.upper() + lower_bound = 0 + upper_bound = len(dictionary_list) - 1 + found = False + + # Loop until we find the item, or our upper/lower bounds meet + while lower_bound <= upper_bound and not found: + + # Find the middle position + middle_pos = (lower_bound + upper_bound) // 2 + + # Figure out if we: + # move up the lower bound, or + # move down the upper bound, or + # we found what we are looking for + if dictionary_list[middle_pos] < key: + lower_bound = middle_pos + 1 + elif dictionary_list[middle_pos] > key: + upper_bound = middle_pos - 1 + else: + found = True + + if found: + print(end="") + else: + print("Possible misspelled word", key, "on line", line_number) + + +main() diff --git a/Lab 12 - Final Lab/final lab.py b/Lab 12 - Final Lab/final lab.py new file mode 100644 index 000000000..668f475f6 --- /dev/null +++ b/Lab 12 - Final Lab/final lab.py @@ -0,0 +1,343 @@ +import random + + +# Game Functions +def intro(): + # Starts the game + print("You are part of an elite counter terrorism task force, responsible for bringing down some of the most " + "dangerous people in the world.") + print("For weeks now, you have been tracking an unidentified target.") + print("All you know is that whoever this individual is, dozens of terrorist attacks can be traced back to them.") + print( + "For a moment you finally had them cornered. However, right before your team could apprehend them, they got away.") + print("You followed them into a hidden underground bunker. You've seen something like this before.") + print("There is a locked door on the far end of this dark room.") + + input("Press any button to continue") + + print("") + print("A prerecorded voice begins to fill the room.") + print("Dear Failed Agent,") + + print("You may have tracked me here, but you will never catch me now. ") + print("I wish you the best of luck with your failure. ") + print("That's when you notice a lock on the dor with three numbers. " + "He may have escaped but he doesn't have to get away. " + "The clues to open it could be in this room.") + print("") + print("You examine the room and see:") + + +# Function which builds a menu which will be called later +def menu(list, questions): + # Function which builds a menu which will be called later + for item in list: + print(list.index(item), item) + + result = input(questions) + + try: + + result = int(result) + + except: + + print("Selection must be a whole number between 0-9") + + return result + + +def door(code): + # Wound up following a tutorial and using try and break to simplify the overall + # code https://www.geeksforgeeks.org/python-try-except/ and https://www.geeksforgeeks.org/python-try-except/. + # This helped solve the issue of the game not ending. Used return instead of true, so it was easier to send the + # loop back to the caller code + # https://realpython.com/python-return-statement/#:~:text=You%20can%20use%20the%20return,further%20computation%20in%20your%20programs. + print("You walk to the door. The rotary padlock contains three digits. You enter a code") + + while True: + + try: + + option1 = int(input("Digit one: ")) + + break + + except: + + print("Digit one must be a whole number between 0-9:") + + while True: + + try: + + option2 = int(input("Digit two: ")) + + break + + except: + + print("Digit two must be a whole number between 0-9:") + + while True: + + try: + + option3 = int(input("Digit three: ")) + + break + + except: + + print("Digit three must be a whole number between 0-9:") + + chosenCode = int(str(option1) + str(option2) + str(option3)) + + print("") + + if chosenCode == code: + + print("As the door clicks open you see him cowering in the corner. You take out your cuffs, a smile" + "spreading across your face as your team moves in. The good guys won today.") + + return 1 + + else: + + print("You jiggle the padlock, but to no avail. The code is incorrect.") + + return 0 + + +def window(choice, codeLocation, codeValue): + print("") + print("You look at the window. It's dark, and damp. " + "Mold grows along the edges and you cannot see through its musty panes.") + + if choice == codeLocation: + print("Carved into the edging, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def briefcase(choice, codeLocation, codeValue): + print("") + + print("The backpack was on the suspects back during the chase. Maybe it still contains intel.") + + if choice == codeLocation: + print("Within the front pocket, you see the number " + str(codeValue) + " written on a crumpled note.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def ashtray(choice, codeLocation, codeValue): + print("") + + print("A cracked ash tray holds the remains of a cigar.") + + if choice == codeLocation: + + print("On the base, you see the number " + str(codeValue) + ".") + + else: + + print("You find no code.") + + print("") + + +def bucket(choice, codeLocation, codeValue): + print("") + + print("The bucket sits in the middle of the floor. It seems to " + "hold " + "bullet casings") + + if choice == codeLocation: + + print("Within, you see exactly " + str(codeValue) + " stones.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def painting(choice, codeLocation, codeValue): + print("") + + print("A gruesome scene depicting atrocities this monster has committed. " + "This fate will fall on many others if you can't crack the code.") + + if choice == codeLocation: + + print("Painted in the corner, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def gemcase(choice, codeLocation, codeValue): + print("") + + print("Thousands of dollars in stollen gems line the inside of this simple box.") + + if choice == codeLocation: + + print("Etched inside the lid, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def rug(choice, codeLocation, codeValue): + print("") + + print("A dusty woven rug adorns the otherwise ragged wooden floor, you notice a corner is turned up.") + + if choice == codeLocation: + + print("Carved onto the floor beneath, you see the number " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def mirror(choice, codeLocation, codeValue): + print("") + + print("The mirror is grimy and unpleasant. " + "The unnatural reflection leers back at you. But you notice it isn't reflecting every detail of the room.") + + if choice == codeLocation: + + print("As you study your reflection, you notice the number " + str(codeValue) + " painted onto your shirt in " + "the reflection.") + + print("") + + else: + + print("You find no code.") + + print("") + + +def bookshelf(choice, codeLocation, codeValue): + print("") + + print("A bookshelf filled with old catches your attention, something is off about them.") + + if choice == codeLocation: + + print("You notice the books are all the same volume. The volume number is " + str(codeValue) + ".") + + print("") + + else: + + print("You find no code.") + + print("") + + +def main(): + # Main game loop + codeSegment1 = random.randint(0, 9) + + codeSegment2 = random.randint(0, 9) + + codeSegment3 = random.randint(0, 9) + + code = int(str(codeSegment1) + str(codeSegment2) + str(codeSegment3)) + + items = ["Door", "Window", "Briefcase", "Ashtray", "Bucket", "Painting", "Gem Case", "Rug", "Mirror", "Bookshelf"] + + code1Location = random.randint(1, 3) + + code2Location = random.randint(4, 6) + + code3Location = random.randint(7, 9) + + intro() + done = False + while not done: + choice = menu(items, "What do you want to inspect? ") + + if choice == 1: + + window(choice, code1Location, codeSegment1) + + elif choice == 2: + + briefcase(choice, code1Location, codeSegment1) + + elif choice == 3: + + ashtray(choice, code1Location, codeSegment1) + + elif choice == 4: + + bucket(choice, code2Location, codeSegment2) + + elif choice == 5: + + painting(choice, code2Location, codeSegment2) + + elif choice == 6: + + gemcase(choice, code2Location, codeSegment2) + + elif choice == 7: + + rug(choice, code3Location, codeSegment3) + + elif choice == 8: + + mirror(choice, code3Location, codeSegment3) + + elif choice == 9: + + bookshelf(choice, code3Location, codeSegment3) + + elif choice == 0: + + result = Door(code) + + if result == 1: + break + + +main() + diff --git a/Lab 12 - Final Lab/part_12.py b/Lab 12 - Final Lab/part_12.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/Testing/test.py b/Testing/test.py index e69de29bb..dd087f07e 100644 --- a/Testing/test.py +++ b/Testing/test.py @@ -0,0 +1,9 @@ +for row in range(10): + + for j in range(row): + print(" ", end=" ") + + for j in range(10 - row): + print(j, end=" ") + + print() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ab9354ea0..ea1018859 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -arcade +arcade~=3.0.0.dev25 + +tcod~=16.2.2 \ No newline at end of file