题目内容
请补全下列利用蒙特卡洛方法完成圆周率的计算的代码:from random import ____ from math import sqrt DARTS = 10000 hits = 0.0 for i in range(1,DARTS + 1): x, y = ____ dist = sqrt(x ** 2 + y ** 2) if dist <= 1.0: hits += 1 pi = 4 * (hits / DARTS) print("Pi值是{}".format(pi))
查看答案
搜索结果不匹配?点我反馈