程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Area of Blue Bridge Cup exercise system circle (Python)

編輯:Python

Problem description

Radius of given circle r, Find the area of a circle .

Input format

Input contains an integer r, Represents the radius of a circle .

Output format

Output one line , Contains a real number , Round to decimal 7 position , Represents the area of a circle .
explain : In the subject , Input is an integer , But the output is a real number .
On the problem of real number output , Please be sure to see the requirements of real output , For example, it is required to keep the decimal point after this question 7 position , Your program must be strict with the output 7 Decimal place , It's not good to output too many or too few decimal places , Would be considered wrong .
If there is no special explanation for the problem of real number output , Rounding is done by rounding .

Reference code

import math
r = int(input())
s = math.pi * r ** 2
# print("%.7f" % s)
print("{:.7f}" .format(s))

Check your knowledge

1. have access to format() Function to specify output precision , You can also use a format string
formate For detailed usage of the function, please refer to the following article
Python Format output format function
For formatted output, refer to the following article
Python Formatted string ( Format output )
2. In mathematics pi need import math


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved