CS 115 Lab 3, Part C: Draw a stack of circles

[Back to lab instructions]


Instructions

  1. In PyCharm, create a new Python file lab03c.py. Copy-paste the following program into the new window, substituting your name for the italicized text:
    """
    Program: CS 115 Lab 3c
    Author: Your name
    Description: Using the graphics package, this program will draw
        a number of circles. 
    """
    from graphics import *
    
    
    def main():
        window = GraphWin("Circles", 800, 800)
    
        # Circle 1
        radius = 50
        x = 100
        y = 100
        center = Point(x, y) 
        circle = Circle(center, radius)
        circle.setOutline('blue')        
        circle.draw(window)            
    
        # Circle 2
        radius = 50                     
        x = 100
        y = 100
        center = Point(x, y) 
        circle = Circle(center, radius)
        circle.setOutline('blue')        
        circle.draw(window)            
    
        # Circle 3
        radius = 50                     
        x = 100
        y = 100
        center = Point(x, y) 
        circle = Circle(center, radius)
        circle.setOutline('blue')        
        circle.draw(window)            
    
        # Circle 4
        radius = 50                     
        x = 100
        y = 100
        center = Point(x, y) 
        circle = Circle(center, radius)
        circle.setOutline('blue')        
        circle.draw(window)            
    
        # Circle 5
        radius = 50                     
        x = 100
        y = 100
        center = Point(x, y) 
        circle = Circle(center, radius)
        circle.setOutline('blue')        
        circle.draw(window)            
    
        window.getMouse()  # wait for the mouse to be clicked in the window.
        window.close()     # close the window after the mouse is clicked in the window.
    
    
    main()
  2. Run the program. You should see only one circle, since the 5 circles are drawn on top of each other. Click in the window to exit the program.
  3. Your eventual goal is to modify the circles until you get the following stack:
    5 circles stacked on top of each other down the left edge of the graphics window
    If you think you know how, answer Question 14 in your writeup and give it a shot! You can skip to Part D once you have it. Otherwise, continue.
  4. Modify the center of the second circle so that it is immediately below, and adjacent to, the first circle. Change its color to red so that you can tell which is which.
  5. Pay close attention to the new y-coordinate and how it relates to the y-coordinates and radii of the other circles. Answer Question 14 in your writeup.
  6. Once your answer to Question 14 is correct, change the remaining circles to draw the full stack.
  7. Once you have the stack of circles, continue to Part D.