首页 > 编程知识 正文

python设计一个圆类,计算周长和面积,用python计算圆面积和圆周长

时间:2023-05-04 10:19:56 阅读:203273 作者:3561

前言

这是我对于”The Practice of Computing Using Python”的读书笔记。

总结了这本书很多有趣的编程题目。初次练手大家轻拍。

Python计算圆的周长和面积

这个程序比较简单,直接上程序了。

#this is the programe taught by the book

#the practice of Python

#By waventroy

import math

radiusString = raw_input("Please input the radius of the circle: n")

radiusInterger = int(radiusString)

circumference = 2 * math.pi * radiusInterger

area = math.pi*(radiusInterger**2)

print "The circumference of the circle is : " ,circumference ,"n",

"The area of the circle is:" ,area

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。