# -----------------------------------------+ # Your name | # Computer Science, Project 5 | # Last Updated: ??, 2021 | # -----------------------------------------| # Use the random module to create a | # simulated ecosystem by stamping randomly | # colored animals in random locations with | # random orientations. | # -----------------------------------------+ import turtle import random # -----------------------------------------+ # create_animal | # -----------------------------------------+ # This function has no parameters. | # -----------------------------------------+ # Create and return a hidden turtle with | # speed 0 and pensize 10. | # -----------------------------------------+ def create_animal(): pass # replace this statement # -----------------------------------------+ # draw_boundary | # -----------------------------------------+ # the_animal: the animal to draw with | # max_x: window's upper right x coordinate | # max_y: window's upper right y coordinate | # -----------------------------------------+ # Draw a rectangle around the window whose | # lower left coordinate is (-max_x, -max_y)| # and whose upper right coordinate is | # (max_x, max_y). | # -----------------------------------------+ def draw_boundary(the_animal, max_x, max_y): pass # replace this statement # -----------------------------------------+ # stamp_animal | # -----------------------------------------+ # the_animal: the animal to draw with | # max_x: window's upper right x coordinate | # max_y: window's upper right y coordinate | # -----------------------------------------+ # Stamp an "animal" at a random coordinate | # in the shape of either a turtle or a | # a "bird" (the "classic" shape) with a | # random color and a random heading. | # -----------------------------------------+ def stamp_animal(the_animal, max_x, max_y): pass # replace this statement # Replace this comment with a comment appropriate for # the fully complete write_message function that follows. def write_message(the_animal, message, message_color, x, y, fontname, fontsize, fonttype): the_animal.goto(x, y) the_animal.color(message_color) the_animal.write(message, font=(fontname, fontsize, fonttype)) # -----------------------------------------+ # The following code controls the logic for| # Assignment 5. Do not make any changes | # to it except to modify the "Program by" | # message to show your name. | # -----------------------------------------+ window = turtle.Screen() stamper = create_animal() how_many = random.randint(10, 20) upper_right_x = window.window_width() // 2 upper_right_y = window.window_height() // 2 draw_boundary(stamper, upper_right_x, upper_right_y) for stamp in range(how_many): stamp_animal(stamper, upper_right_x, upper_right_y) message = "Animals = " + str(how_many) write_message(stamper, message, "black", -75, -200, "Ariel", 20, "bold") message = "Program by Mr. Koenen" write_message(stamper, message, "purple", -75, -225, "Ariel", 12, "normal") window.exitonclick()