python如何开根号

Python

1个回答

写回答

Zq8888588

2023-06-27 19:15

+ 关注

Python
Python

Python中,可以使用math模块中的sqrt()函数开根号。示例代码如下:

Python

import math

num = 4

result = math.sqrt(num)

print(result) # 输出2.0

如果想开任意次方根,可以使用幂运算()对数值进行处理,例如开三次方根:

Python

num = 27

result = num (1/3)

print(result) # 输出3.0

举报有用(17分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号