Generation

generate functionWed, 16 Nov 2022

(ncount/n)*4.0を求めよ

def pi(n): ncount = 0 for i in range(n): x = random.random() y = random.random() if x*x + y*y <= 1: ncount = ncount + 1 return (ncount/n) * 4.0

Questions about programming?Chat with your personal AI assistant