0
円内の点の座標を計算する方法を理解できません。今私のプログラムは、四角形内の円の中の点を計算し、それをドットの総量で割ったものです。亀のグラフィックを使用して、Pythonの円の直径を見つける方法
import turtle
import random
t=turtle.Turtle()
insideCircleCount = 0
def square():
for y in range(4):
t.forward(200)
t.left(90)
def circle():
t.penup()
t.setpos(100,0)
t.pendown()
t.circle(100)
def randomDot():
z=int(input("iterations:"))
for y in range(z):
t.penup()
t.pensize(1)
x=random.randint(0,200)
y=random.randint(0,200)
t.goto(x,y)
t.pendown()
t.dot()
insideCircle(x,y)
def insideCircle(x,y):
if ((x*x + y*y)<100):
insideCircleCount+=1
#main
square()
circle()
randomDot()
print('Dots inside circle account for ', insideCircleCount)
あなたは 'insideCircle'やサークルの中心に置かY、X間の距離を計算する必要があります。それ以外の場合は100未満のyoureの内部。宿題のようなにおいがあなた自身で解決されます。 –