Due: Tuesday, February 14, 2017, 11:59 pm
The goal of this assignment is to give you practice in creating and using functions and function parameters in Python. You'll continue to create shapes using turtle graphics, just like we did in lab.
The end result of the assignment should be a representation of a scene depicting something in Coastal Maine.
Remember that you need to write the code yourself. You can discuss the assignment and ideas regarding the assignment with others in English, but not Python. If you have questions about your Python code (other than very simple syntax questions), please ask one of the lab assistants or professors. Please see the syllabus for guidelines on collaboration and attribution.
Your first task is to create a main.py file that imports your shapelib.py functions. To do this, create a file called main.py in a text editor, and at the top (after your name and a date) put the following.
In your main.py file, make a function called coast1. Put a single call to the coast1 function at the end of the file, followed by a raw_input call.
Write some python code in your coast1 function that
calls some of the functions from your shapelib.py file
to draw a simple image (like a few blocks). Note that to call a
function from your shapelib file you have to prepend
shapelib. in front of the function name. For example
shapelib.block( 10, 10, 20, 30 ) would be how you would
call the block function.
You can run your main.py file using:
You don't need to save this image, as you'll be replacing the code in the coast1 function later on.
Each of your shapes should draw properly no matter where it is drawn on the screen, what the size parameter is, or what the orientation of the turtle happens to be when the shape function executes. Test this out for all of your functions.
In your writeup, include a picture demonstrating that your shape functions work properly. This is required picture 1.
When you have a picture or scene you want to save, make a screen capture of it on a mac using the key combination Command-Shift-4. The picture will automatically be saved to a file on your Desktop. You can then move and rename it to a more appropriate location. Make sure the entire scene is visible in the image.
When you define these aggregate shape functions, they should all take at least three parameters. The first two (x0, y0) will define the starting location for the shape and the third should define the scale of the shape. A scale factor of 1.0 should draw the shape in its natural size. Feel free to add additional parameters as you like to control other aspects of the shape. As with the basic shapes, your shapes should draw properly at any scale, location, or turtle orientation.
Note that for basic shapes, we want a size parameter (in pixels) whereas for aggregate shapes we want a scale parameter instead. The scale parameter is used to resize all the basic shapes that make up the aggregate shape.
For a little more detail on making aggregate shapes, see the geometric thinking page.
In both of your new functions, use one or more of the basic shape functions to draw the shape. For example, a pine tree might incorporate the block and triangle functions. Test out your new functions before proceeding.
In your writeup, include a picture demonstrating that each of your aggregate shape functions work properly. That means drawing it in several locations at several scales. This is required picture 2.
Save the image and include it in your writeup. This is required picture 3.
Save the image and include it in your writeup. This is required picture 4.
Each assignment will have a set of suggested extensions. The required tasks constitute about 83% of the assignment, and if you do only the required tasks and do them well you will earn a B. To earn a higher grade, you need to undertake one or more extensions, which give you the opportunity to tailor the assignment to your own interests.
How well you complete the main assignment, combined with the difficulty and quality of any extension or extensions you complete will determine your final grade for the assignment. One complex extension, done well, or 2-3 simple extensions are typical.
Then you can use it to generate random integers using the following expression, where a and b are the upper and lower bounds of the random numbers you want.
Turn in your code by putting it into your private hand-in directory on the Courses server. All files should be organized in a folder titled "Project 2" and you should include only those files necessary to run the program. We will grade all files turned in, so please do not turn in old, non-working, versions of files.
Make a new wiki
page for your assignment. Put the label
the label field on the bottom of the page. But give the page a meaningful
title (e.g. Ying's Project 2).
In general, your intended audience for your write-up is your peers not in the class. Your goal should be to be able to use it to explain to friends what you accomplished in this project and to give them a sense of how you did it. Follow the outline below.
© 2017 Ying Li. Page last modified: .