2012-02-12 11 views
-1

プログラムを実行しようとすると構文エラーが発生し、最後の行の印刷が赤で強調表示されます。なぜ構文エラーがあるのか​​分かりません。pythonのprintステートメントで無効な構文エラー3.2.2

# 6. Calculate the radius of the circle using the 
#  distance formula on a given point and the center 
r = math.sqrt((a-x)** + (b-y)** 

# 7. Output to the shell the location of the center 
# of the circle 
print("The center of the circle is at (",x,",", y,")",sep="") 

# 8. Output to the shell the radius of the circle    
print("The radius of the circle is " , r) 

答えて

2
r = math.sqrt((a-x)** + (b-y)** 

はおそらく

r = math.sqrt((a-x)**2 + (b-y)**2) 

行方不明閉じ括弧あるべき式は次の行に広がってます。最後の行でprint()コールまで、式はPythonの文法に従います(これは最初は驚くようです)。

+0

私はあなたが示唆したようにしようとしましたが、私はその閉じかっこで無効な構文エラーを取得しました。それをした – Jahe234

+0

。どうもありがとうございます! – Jahe234

関連する問題