Deadline: Tu 1/27/2015 at 7 AM
Review the Week 1 reading on variables and assignment as necessary to complete this section.
x = "I" y = 'see' x = "what" x = 'you' y = "did there!"Then click "Visualize execution."
In Lab 2, you will write a text-based program that takes one numeric value from the user and does a bunch of math with it.
In the example below, the user's input is italicized and underlined, and all of the other text is output from the program you'll write:
Enter a numeric value: 10
The area of a square with side length 10.0 is 100.0.
The area of a circle with radius length 10.0 is 314.159.
The volume of a cube with edge length 10.0 is 1000.0.
The volume of a sphere with radius length 10.0 is 4188.790.
The area of an equilateral triangle with side length 10.0 is 43.301.
Here's a different example, where the user enters a value of 5.2:
Enter a numeric value: 5.2
The area of a square with side length 5.2 is 27.04.
The area of a circle with radius length 5.2 is 84.949.
The volume of a cube with edge length 5.2 is 140.608.
The volume of a sphere with radius length 5.2 is 588.977.
The area of an equilateral triangle with side length 5.2 is 11.709.
Here are the formulas to compute these five quantities:
Using any tools you like, answer Question 2 in your pre-lab.
Now it's time to translate the math into Python. Question 3 in your pre-lab covers Python math, which we'll discuss in more detail on Tuesday.
To answer this question, refer to the "Arithmetic" section of the Week 2 reading assignment, and use the online tutor if you get stuck.
To draw objects in a graphics window, you can describe a point
as a pair of coordinates $\left(x, y\right)$, just like in math.
But there is one big difference: in the graphical system, the top left point is $(0, 0)$, and the y-coordinates actually get larger as you go down:
The specific values depend on the width and height of the window. For example, if the window is 800x800 pixels (what we'll be using in Lab 2), then the top right point is $(800, 0)$.
Answer Questions 4 and 5 in the pre-lab. Question 5 asks you to think about a 100x100 square centered in the graphics window, like this:
Question 5 doesn't affect your grade, but we encourage you to give it a try; it's worth thinking about before the lab.
Review your answers, and then click the Next button at the bottom of the Moodle quiz.
Once you do that, you should see something similar to this:
Click the Submit all and finish button. You MUST do this so that your
writeup can be graded! Once you have submitted your quiz, you should see
something similar to this at the top of your Moodle window. The important part is that the State shows up as Finished.