#
# ps8pr2.py (Problem Set 8, Problem 2)
#
# Estimating pi
#
# Computer Science 120
#

import random
import math

def throw_dart():
    """ Simulates the throwing of a random dart at a 2 x 2 square that.
        is centered on the origin. Returns True if the dart hits a circle
        inscribed in the square, and False if the dart misses the circle.
    """
    
    # pick an x and y value between -1.0 and +1.0 inclusive.
    x = random.uniform(-1.0, 1.0)
    y = random.uniform(-1.0, 1.0)

    # Check if the x and y values are within the unit circle
    # This is just the pythagorean theorem a^2 + b^2 = c^2
    # Any c^2 less than 1.0 is in the circle of radius 1
    
    if x**2 + y**2 <= 1.0:
        return True
    else:
        return False    
    # Alternative return statement
    # a more compact version of the same code
    # return x**2 + y**2 <= 1.0



### PUT YOUR WORK FOR PROBLEM 2 BELOW. ###
