私のコードでは、すべての座標の組み合わせを試して、指定した円の中にいくつの点があるのかを数えることができます。 私は私のコードを実行するたびに、私はここでValueError: math domain error
Python 3で数字を四角形にすることはできません
取得すること
def findPoints(radius):
x = 0
y = 0
centre_x = 0
centre_y = 0
numOfPoints = 0
allFound = False
while allFound == False:
print(str(numOfPoints) + " :::: " + str(x) + "::" + str(y))
dist = math.sqrt(centre_x - x)**2 + (centre_y - y)**2
if dist < radius:
numOfPoints = numOfPoints + 1
x = x + 1
if x == radius:
x = 0
y = y + 1
私は、あなたが決して 'centre_x'を増やさないので、あなたは負の数のsqrtを取ろうとします。 – Karin