''' DS2000 Spring 2020 Sample code -- graphics with Python Turtle (also a demo of a void function, and of using random) January 17, 2020 ''' import turtle import random def draw_square(color, size): ''' Function draw_square Input: color (string), size (int) Returns: nothing Does: Draws a square at a random location. It creates a turtle (Rafael), and calls functions to move the turtle around the screen. ''' x_coord = random.randint(-100, 100) y_coord = random.randint(-100, 100) rafael = turtle.Turtle() rafael.penup() rafael.goto(x_coord, y_coord) rafael.color(color) rafael.pendown() rafael.forward(size) rafael.right(90) rafael.forward(size) rafael.right(90) rafael.forward(size) rafael.right(90) rafael.forward(size) def main(): draw_square('blue', random.randint(50, 300)) draw_square('yellow', random.randint(50, 300)) draw_square('pink', random.randint(50, 300)) draw_square('orange', random.randint(50, 300)) main()