Due Date: Thursday of week 02

The following guidelines are expected for all homework submissions:

Problems for Assignment #1

Learning Outcomes: 1) make sure your Python Development Environment is working; 2) make sure your GitHub repo is set up and accessible; 3) make sure you can check code into your repo; 4) learn the basics of python on a simple simulation

This assignment is actually really easy. All you need to do is:

  1. Get your GitHub account set up; use the naming convention CMSI-3630_<your_name> so I can easily tell which one is which
  2. Create your repository with all the required folders; use the empty file README.md to start the folders [GitHub won't let you create just an empty folder ~ you need something in it]
  3. Make sure that the folder structure is set up the same as on the week one page under the Assignment Submissions section
  4. Make sure that the repository is PRIVATE for reasons explained in class
  5. Invite your professor to participate in your repository; my GitHub name is bjohnson05 and my squirrel drinking coffee logo should be visible
  6. Be sure to check that your code runs from the command line, the REAL one, not one that is part of an editor or IDE like Eclipse or VScode
  7. Commit one copy of your week one in-class exercise to your homework01 directory

Part Two: As Shown In Class ~ piSolver.py

OUR FIRST SIMULATION ALGORITHM!

One easy way to determine the approximate value of PI is to use what's known as the Monte Carlo simulation. To do this, implement the following steps:

  1. Imagine a unit circle which is a circle with a radius of one
  2. Inscribe that circle inside a square, so that the four sides of the square are tangent to the circle on four sides; this means you have a square that is 2 units by two units with the circle inside it
  3. Now imagine throwing a large bunch of darts that RANDOMLY land inside the square; some will land in the circle, some will land in the square OUTSIDE the circle
  4. Given the area of the square is Areasquare = 2 * 2 = 4 units
  5. Given the area of the circle is Areacircle = PI * r * r and since r = 1, then Areacircle = PI units
  6. Taking the ratio of Areasquare to Areacircle give the equation Areasquare / Areacircle = 4 / PI
  7. Rearranging that equation gives PI = (Areacircle * 4) / Areasquare
  8. OK, now we can create a program for this! See if you can write a program in Python that will give an approximate value of PI using Monte Carlo Simulation. The steps are as follows:
    1. Generate a large number of random X and Y paired values to simulate points where darts hit
    2. Count how many total points there are to simulate the area of the square
    3. Calculate the distance of each point from the center [origin] of the circle; if it is less than or equal to one, that dart is INSIDE the circle so count it
    4. When all darts are thrown, use the total number thrown as Areasquare and the total count INSIDE the circle as Areacircle
    5. Calculate and output the approximate value of PI using the equation developed above