>> 2.**.5 1.4142135623730951 >>> import math >>> math.sqrt(2) 1.4142135623730951 >>>" />

如何在python中算根号2

$ python Python 2.7.2+ (default, Jul 20 2012, 22:12:53) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 2.**.5 1.4142135623730951 >>> import math >>> math.sqrt(2) 1.4142135623730951 >>>
如何在python中算根号2
1、创建python文件,testmath.py;

2、编写python代码,计算根号2;
import math
print(math.sqrt(2))

3、右击,选择‘在终端中运行Python文件’;

4、查看执行结果为1.4142135623730951;

2020-02-13
$ python
Python 2.7.2+ (default, Jul 20 2012, 22:12:53)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 2.**.5
1.4142135623730951
>>> import math
>>> math.sqrt(2)
1.4142135623730951
>>>2013-10-24
导入数学模块,用sqrt函数计算

import math
print(math.sqrt(2))2013-10-24
x**0.5 或者 math.pow(x, 0.5)2013-11-15
还有一个
pow(2, .5)2013-10-24
mengvlog 阅读 53 次 更新于 2025-10-30 21:17:49 我来答关注问题0
檬味博客在线解答立即免费咨询

Python相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部