import random


def calc_pi(N):
    """ Estimates pi using Monte-Carlo """
    M = 0 # Initialize the counter
    for i in range(N):
        # Simulate impact coordinates
        x = random.uniform(-1, 1)
        y = random.uniform(-1, 1)

        # True if impact happens inside the circle
        if x**2 + y**2 < 1.0:
            M += 1

    return 4 * M / N