Compsci 101, Fall 2014
Assignment 3 - Turtle Picture

Click here for sample student pictures

NOTE on Sept 13, 11am - Added a file with the flower pattern in it that you can cut and paste to see it run. The file is below the picture of the flower pattern.

NOTE on Sept 12, 3pm - Added an example of a pattern of a flower below, and also gave a examples of turtle commands you have already used

There is no howto page for this assignment. All instructions are on this page.

Programming has long been used to create or supplement artistic works, from such as in exhibits in museums. Daily it is used by visual designers, artists, and architects to create their works. Software has engaged a new generation of visual artists to consider programming as an essential part of their creative practice.

Logo is a computer programming language designed to teach programming to children. It is a user-friendly, interpreted language, designed with a "low floor, high ceiling"; in other words, the designers of Logo intended for the language to allow novice programmers to get started quickly writing programs but also wanted the language to be powerful and extensive for more advanced users. In the last 40 years, Logo has also caused people to think differently about how to teach art, geometry, social science, and complex systems.

The basic commands to move and turn a "turtle" (originally a physical robot) are so much a part of programming history that they have been incorporated into almost every modern programming language, Python included. We will use this basic system to explore programming. Examples of using the turtle are given in the course textbook and you can use any of the Active Code boxes in the text book to complete this project if you do not yet have Eclipse installed.

In this assignment you will use the Python Turtle graphics to create a picture. This assignment will give you a chance to work on functions and loops and to learn new turtle functions. It is also a creative assignment that you can have some fun with. There are specific requirements you will need to follow to get full credit.

The textbook has already shown you several turtle commands. There are many more in Python's Turtle Graphics module.

Requirements

To get full credit you must follow these requirements.
  1. You must put all your code in one Python module named Picture.py

  2. You must have a function called draw that has no parameters, and that can only create turtles and call other functions.

  3. You must use at least one turtle. Feel free to use more.
  4. You must have the following if __name__ = '__main__': in your program to start it and it should only call draw .
    if __name__ == '__main__':
        draw()
    
  5. You must have at least 6 useful functions in your program, besides the function draw.

  6. You must have at least TWO functions that have a for statement ("a loop") that generate different patterns (examples might be a square, a window, a spiral, etc) and are each called and displayed in the picture at least twice. (these 2 functions would be two of the six required functions. )

    Here is example code for a function that draws a flower pattern. Also is a statement that calls the function.

    SINCE I AM GIVING YOU THIS FUNCTION, you can use it if you want, but it does not count as one of the six functions that you are suppose to create! If you modify it in some way, (possibly add colors or fill in), then you can count it as one of your functions.

    def flowerSquare(alex):
        for i in range(12):      # repeat twelve times
            # draw a square
            alex.forward(50)
            alex.left(90)
            alex.forward(50)
            alex.left(90)
            alex.forward(50)
            alex.left(90)
            alex.forward(50)
            alex.left(90) 
            # move 30 degrees 
            alex.left(30)
            
    flowerSquare(alex)
    
    

    and here is the picture of the flower pattern:

    Here is a Python file turtleFlower.py that uses the flowerSquare function and draws a flower.

  7. You must use at least fifteen different turtle methods.

    The textbook has already shown you several turtle methods.

    For example, here are five turtle methods you have probably already used:

     forward
     left
     right
     up
     down
    

    There are many more in Python's Turtle Graphics module.

    None of the following below count as the required fifteen different turtle methods.

    # setup steps: no need to change for now                                                                   
    import turtle               # allows us to use the turtles library                                         
    wn = turtle.Screen()        # creates a graphics window       
    
    def draw():
        alex = turtle.Turtle()      # create a turtle named alex    
    
        
    if __name__ == '__main__':
        draw()
     
        # the next line should be the last line in the file   
        wn.exitonclick()         # window stays up til clicked on
    

  8. You must use at least three colors that are displayed in the picture.
  9. You must use at least one polygon that is filled in with a color (not the default color of the canvas).
  10. You must use exitonclick() as the last statement in your program so the canvas will stay up until it is clicked on.

Getting Started

You can start with this simple program, or snarf it or copy it from here.

'''
Created on Sep 3, 2014

@author: YOUR NAME HERE
'''
import turtle               # allows us to use the turtles library                                         
wn = turtle.Screen()        # creates a graphics window                                                    
                                           
                                                                                   

def rightAngle(turt):       # This function is a sample, you can delete it 
    turt.forward(100)
    turt.left(90)
    turt.forward(100)
    
def draw():
    alex = turtle.Turtle()    # you can rename the turtle if you want
    rightAngle(alex)   
 
if __name__ == '__main__':
    draw() 

wn.exitonclick()

Your grade will be based on how well your program conforms to the standards above and whether it draws a picture using the function named draw. It's possible to earn extra credit for artistic creativity.

Submit your Python module using Ambient from Eclipse and the assignment named picture.


What to Submit

Please submit the following via Eclipse/Ambient/submit or websubmit: