In this assignment you are tasks with writing a program which inputs the radius of a circle, and outputs the circumference and area of that circle. Feel free to lookup the formulas online.
We will use the Write - Refactor - Test - Rewrite approach to complete the final solution which uses functions.
NOTE import math
then use math.PI
to get the value of Pi https://en.wikipedia.org/wiki/Pi
In [14]:
import math
## TODO: Write the solution here Step 1
In [13]:
## Step 2: Refactor into two functions def CircleArea... and def CircleCircumference
Time to test. Write two tests, once for each function
WHEN radius=1 We EXPECT CircleArea(radius) to return 3.141593
WHEN radius=1 We EXPECT CircleCircumference(radius) to return 6.283185
Make sure you call the function to get the actual, just like in the coding lab.
NOTE: If its accurate to 4 decimal places, that's sufficient. The test values might be different because of how the "%f" format code works.
In [12]:
# Step 3: Write tests.
In [11]:
## Step 4: Write program here from the algorithm above
Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?
To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.
Keep your response to between 100 and 250 words.
--== Write Your Reflection Below Here ==--