Created
December 14, 2017 08:36
-
-
Save ExReanimator/889eb3ab44fc6e93fb669b7fa16bdcb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def inOut(x, y): | |
if x + y <= 1: | |
return True | |
else: | |
return False | |
def calc_pi(n): | |
return 4/n | |
for sample in [1000, 10000, 100000, 1000000]: | |
x = random.random() | |
y = random.random() | |
if inOut(x,y): | |
print("For a sample " + str(sample) + " and random point("+ str(x) + ", " + str(y) +") Pi is " + str(calc_pi(sample))) | |
else: | |
print("For a sample " + str(sample) + " and random point("+ str(x) + ", " + str(y) +") point is out of range") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment