輸入半徑計算圓面積的代碼:#計算圓的面積(第一行)、from math import pi(第二行)、r=float(input('輸入半徑的長度:'))(第三行)、area=pi*r**2(第四行)、print('輸出圓的面積:',area)(第五行)。
方法一:
r=int(input('請輸入圓半徑:'))
s=3.14*pow(r,2)
print('圓面積為:{:.2f}'.format(s))
方法二:
import numpy
r=input('請輸入圓半徑:')
print('圓面積為:{:.2f}'.format(3.14*(numpy.square(float(r)))))
方法三:
Import math
pi=math.pi
Def circle_area():
r=float(input('請輸入半徑:'))
s=pi*r*r
print('圓面積為:{:.2f}'.format(s))
circle_area()
方法四:
r=int(input('請輸入圓半徑:'))
s=3.14*pow(r,2)
print('圓面積為:{:.2f}'.format(s))
圓的周長=2*π*r;圓的面積=π*r*r。
計算圓的面積和周長的代碼:
#計算圓的周長和面積:
r=int(input("請輸入圓的半徑(整數(shù)):"))
area=3.14*r*r
C=2*3.14*r
print("圓的面積是:{:.2f}".format(area))
print("圓的周長是:{:.2f}".format(C))
大學(xué)院校在線查
高考熱門一鍵查
有疑問就來發(fā)現(xiàn)