from random import random
times =int(input("请输入掷飞镖次数:"))
hits =0for i inrange(times):
x = random()
y = random()if x*x + y*y <=1:
hits+=1print(4.0*hits/times)
使用蒙特·卡罗方法计算圆周率近似值from random import randomtimes = int(input("请输入掷飞镖次数:"))hits = 0for i in range(times): x = random() y = random() if x*x + y*y <=1: hits+=1print(4.0*hits/ti...