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")