Python中怎么计算圆周长?

1,799次阅读
没有评论

Python中怎么计算圆周长?

Python中怎么计算圆周长呢?

1、首先输入圆的半径

2、其次将输入的半径转换成浮点型,便于精确计算

3、利用圆周长公式C = 2πr进行计算

4、输出计算结果

import math
radius1 = input("radius of cricle:")
radius2 = float(radius1)
circumference=2*math.pi*radius2
print("circumference of circle:",circumference)

其中π的使用需要导入math模块。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python基础教程2022-12-07发表,共计241字。
新手QQ群:570568346,欢迎进群讨论 Python51学习