This lab has two parts, one of which should be started before lab so that everyone is not trying to download the software at the same time.
If you have any questions about the course, post your questions to Piazza, the course discussion forum. You will need to sign up for an account on Piazza using your Duke email address.
Turn in this page for your group
In order to write programs, you will need some other programs. These allow you to edit your program, translate it into a simpler representation that your computer can understand, and run it. These initial steps may seem a little overwhelming, but they only need to be done once to get things started and working together.
compsci06spring11
). You can put your workspace anywhere, but you will need to remember where it is later in the semester.http://www.cs.duke.edu/courses/cps006/fall11/snarf
06fall11_lab01
has been created you are ready to test your installation and experiment with Python code.To run the code, open up the project file in src
called graphing.py
by double-clicking on it, then use the green Play button on the toolbar. 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!
To experiment with the code, look at the file graphing.py
, and try to figure out generally how it works. To direct your experimentation, do the problems below that require you to change the file graphing.py
, run it to see the results, and write down your answers on the handin pages.
y = x2 - 7x + 20
over the range, x-values, [0, 5]
. Change the program so it graphs the same expression but instead between the x-values 0 and 20.y = (x-4)3
over the range [0, 10]
.y = sin(x)
over the range [0, 10]
. To use the sin
function you will need to write math.sin(x)
instead of just sin
is in the math library, not built directly into Python. functionToGraph
to the following:
return random.randint(0,20)