【发布时间】:2013-12-02 17:21:33
【问题描述】:
我对 ** 运算符在 python 中的含义有些困惑
import math
radius = raw_input("Enter your radius")
area_of_circle = radius ** math.pi
print area_of_circle
我要做的是弄清楚** 运算符会做什么。这是针对Codeacademy 上的一个问题,涉及求平方根。请不要给我答案,只是关于获得平方根的语法建议。
【问题讨论】:
-
docs.python.org/2/library/operator.html“圆的面积”应该给你一个线索。 ...“pi 是平方的”(大声说出来...)
-
**与to the power of相同 -
而
x与1/2的幂是...(尽管如果您尝试calculate the area of a circle,您确定平方根是您想要的吗?) -
再次检查您的源代码,您在此处粘贴的代码看起来不对。
-
是的,
radius ** math.pi绝对不是圆的面积方程:|
标签: python python-2.7 exponentiation