Another Monte Carlo angle:
import random
n=1000000
print(4.*sum(random.random()**2 + random.random()**2 < 1 for i in range(n))/n)
Both this version and the Buffon's Needle version are a lot less efficient than the version in this article, because the article's version is making educated guesses about where the boundary is, while the randomized versions are making uneducated guesses. :-)
pi is approximately: (2 x the stick length * the number dropped) divided by (the distance between lines * sticks crossing a line)
[0] https://en.wikipedia.org/wiki/Buffon%27s_needle_problem
[1] https://ogden.eu/pi/