第 4 步:让我们计算圆的面积。一个圆的面积是 πr 2 ,所以我们需要创建一个变量来存储这个值。

  • 在逻辑选项卡中,单击并拖出my_circle下方Float Variable
  • 将变量名从my_var更改为circle_area
  • circle_area的值从2.34更改为方程3.14 * ( 25 / 2 ) ** 2

3.14 是 π 的值,半径是我们的直径除以 2,** 2 是如何在 Python 中对一个数字求平方!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)