Turn in this page for your group
You should report on how many pages you could create. Each page must have at least one four letter word in it. Otherwise the page can be blank. You create pages by inserting page breaks. You can use copy, select all, paste, or any other word features.
You should submit the number of pages you created and, more importantly, the mechanism, strategy, or algorithm you used expressed in a form so that someone else could replicate the strategy.
Try to get Eclipse and Python installed before lab using the install pages as a guide. If you don't, we'll be using files stored on flash/thumb drives that are available in lab to install Java, Eclipse, the Enthought Python package (EPD), the Eclipse Pydev plugin, and the Duke Ambient plugin.
Create a workspace for compsci06spring11. You can put this anywhere, but you might as well create the workspace in some location you'll remember (a folder for courses, Compsci06, etc.)
When you are done with this, you should be able to "snarf" the code for Lab 1 through Eclipse and run it as discussed below.
See this site for help with Snarfing. In general to snarf the code, click the "Browse Snarf sites" button, then click the "Add a new project site" button. You should add this site:
http://www.cs.duke.edu/courses/cps006/spring11/snarf
This will show you both APT and Lab categories/folders. First you'll snarf/download the code for Lab1 to install it on your machine. This should allow you to snarf the "Lab1" code and install it on your machine.
To run the code, open up the
graphing.py
file by double-clicking on it, then use the
green "Run" button. You may have to choose what kind of Python run to
use depending on your Python settings (choose Python Run if you
have a choice).
Running the program should create and display a graph. You may get a small rocket-shaped icon representing the open graph.
If that worked, everything is installed correctly! Look at the code, and try to figure out how it works. Do the problems below and write down your answers on the handin pages
graphing.py
in the function labeled main
,
figure out how to graph the function between the x-values 0
and 20. Edit the code, run it, and note on the handin pages what change you made.
functionToGraph
so that it graphs y = (x-4)3
between the x-values 0 and 10. What changes did you make to
the Python function functionToGraph
(note on the
handin pages)?
math.sin(x)
because sin is in the
math library. How many complete cycles of the sine wave are
there between 0 and 10?
functionToGraph
to the following:
return random.randint(0,20)What do you see and why? Note this on the handin pages
Navigate to the snarfed code and create a new Python module (Python file) named Bogsquare. You do not include the .py suffix when creating the module; Eclipse will supply this. Create the function score as shown in the APT:
def score(word): return 4and fill in the body of the function as shown so that it returns 4. Test the APT using the instructions here and verify how many green/passes there are. Write that number on the handin pages.