在 Python 程式中求圓柱的周長
在本文中,我們將瞭解如何解決以下問題陳述 −
問題陳述
輸入直徑和高度,求圓柱的周長。
周長就是圓柱的側面檢視,即一個矩形。
因此 周長= 2 * ( h + d )
其中 d 是圓柱的直徑
h 是圓柱的高度

現在讓我們看看實現方法
示例
# Function to calculate the perimeter of a cylinder
def perimeter( diameter, height ) :
return 2 * ( diameter + height )
# main
diameter = 5 ;
height = 10 ;
print ("Perimeter = ",perimeter(diameter, height))輸出
('Perimeter =', 30)所有變數和函式均在全域性框架中宣告,如下圖所示。

結論
在本文中,我們學習瞭如何使用 Python 3.x 或更早版本求圓柱的周長。
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP