python calculate area of circle

silencement
Release: 2019-06-05 11:41:15
Original
50054 people have browsed it

python calculate area of ​​circle

How to calculate the area of a circle using python?

First of all, we need to know the formula for calculating the area of a circle: S = πr². In the formula, S is the area of the circle required, π is the pi ratio, and r is the radius of the circle.

Example

# 定义一个方法来计算圆的面积 def findArea(r): PI = 3.142 return PI * (r*r); # 调用方法 print("圆的面积为 %.6f" % findArea(5));
Copy after login

In the above example we defined a findArea() function, the parameter r is the radius of the circle, the pi is 3.142, and the return value of the function is PI * (r *r), which is the area of the circle.

For more python related technical articles, please visitpython tutorialto learn.

The above is the detailed content of python calculate area of circle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!