Monte Carlo import random import matplotlib.pyplot as plt import numpy as np 6 # 函数模拟点的随机掉落,并分为两组 def check(tmp): global ans, ansX, ansY global inX, inY global outX, outY tmpX = random.random() tmpY = random.random() if (tmpX ** 2 + tmpY ** 2) <= 1:…