Try   HackMD

19-3:圓面積與體積

Chinglin-K


目錄:Dice 程式教學-Python完整版
上一篇:19-2:圓柱體體積
下一篇:19-4:x的y次方


題目

輸入半徑與高,計算圓柱體體積(圓周率=3.14)。

輸入範例:
3 4
5 5
6 6
11 15
6 6
73 4
40 4
6 8
8 9
10 10

輸出範例:
圓柱體體積113.04
圓柱體體積392.50
圓柱體體積678.24
圓柱體體積5699.10
圓柱體體積678.24
圓柱體體積66932.24
圓柱體體積20096.00
圓柱體體積904.32
圓柱體體積1808.64
圓柱體體積3140.00


程式碼

def volume(r): return r * r * 3.14 def area(r,h): return volume(r) * h for i in range(10): r,h=map(int,input().split()) #r=int(input()) #h=int(input()) print(f'圓柱體體積{area(r,h):.2f}')

輸出


目錄:Dice 程式教學-Python完整版
上一篇:19-2:圓柱體體積
下一篇:19-4:x的y次方


「盡多少本分,得多少本事」😊