【问题标题】:How to get Square root of a number without import anything in python? [closed]python - 如何在不在python中导入任何内容的情况下获得数字的平方根? [关闭]
【发布时间】:2020-07-13 09:12:23
【问题描述】:

如何在没有在 python 中导入任何内容的情况下获得数字的平方根? 你知道我们可以做到这一点:

import math
a = 4
s = math.sqrt(a)

但我想在不导入任何库的情况下更简单地做到这一点。

【问题讨论】:

    标签: python python-3.x python-2.7 python-import math.sqrt


    【解决方案1】:

    您可以在 python 行中使用 Exponentiation 来做到这一点:

    a = 4
    b = a ** 0.5    #(1/2)
    

    【讨论】:

      猜你喜欢
      • 2020-08-10
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      • 2018-08-10
      • 2023-02-10
      • 2012-08-19
      相关资源
      最近更新 更多