Compsci 6, Spring 2011, Lab 1

This lab has two parts. You'll be working on algorithmic problem solving and thinking in groups of 3 to 4 students. You'll also work to make sure the programming environment we're using works on your own laptop (that you'll need to bring to lab if you can't install Eclipse before lab).

  1. Crash/break Microsoft Word by making a huge file.

  2. Install Python and the software we use to work with it. This will include running some programs to make sure Python is working for you.

Turn in this page for your group

Giant Microsoft Word File

Start Microsoft Word. Change the preferences for saving so that the Word program never autosaves. Then come up with a strategy or algorithm to determine the largest in terms of pages document you can create before Microsoft slows down so much as to be useless, or crashes, or provides an error message that is equivalent to crashing such as "No, I'm sorry Dave, I cannot do that".

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.

Install Python and related software

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

Snarf and Run Lab1 Code

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

  1. The graph shown is the graph of y = x2 - 7x + 20 between the x-values of 0 and 5. Looking at the Python module 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.

  2. Change the function graphed in the Python function 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)?

  3. Graph the function y = sin(x) between the x-values of 0 and 10. To use the sin function you'll need to write math.sin(x) because sin is in the math library. How many complete cycles of the sine wave are there between 0 and 10?

  4. Graph a function where the y-value is chosen at random by changing the body of functionToGraph to the following:
        return random.randint(0,20)
    
    What do you see and why? Note this on the handin pages

Snarf, Create, Test APT Bogsquare

Snarf the testing code for the Bogsquare APT due next week.

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 4
and 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.