在 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