Python计算圆的周长及面积
数学计算公式
圆的半径r
perimeter = 2r∏
area = r^2*∏
Python代码
`
"""
计算圆的周长和面积
"""
import math
def perimeter(r):
return 2rmath.pi
def area(r):
return r**2*math.pi
def main():
r = int(input('请输入圆的半径(cm):'))
print('圆的半径%d(cm)时,周长为:%0.2f(cm),面积为:%0.2f' % (r,perimeter(r),area(r)))
if name == 'main':
main()
`