MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / is_in_circle

Function is_in_circle

maths/monte_carlo.py:24–28  ·  view source on GitHub ↗
(x: float, y: float)

Source from the content-addressed store, hash-verified

22
23 # A local function to see if a dot lands in the circle.
24 def is_in_circle(x: float, y: float) -> bool:
25 distance_from_centre = sqrt((x**2) + (y**2))
26 # Our circle has a radius of 1, so a distance
27 # greater than 1 would land outside the circle.
28 return distance_from_centre <= 1
29
30 # The proportion of guesses that landed in the circle
31 proportion = mean(

Callers 1

pi_estimatorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected