酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

Python:实现输入长方柱长宽高并计算输出体积的面向对象程序

class Cuboid: def __init__(self, length, width, height): self.length = length self.width = width self.height = height def calculate_volume(self): return self.length * self.width * self.height cuboids = [] for i in range(3): l, w, h = map(int, input().split()) cuboid = Cuboid(l, w, h) cuboids.append(cuboid) for cuboid in cuboids: volume = cuboid.calculate_volume() print(volume) ######[AI写代码神器 | 299点数解答 | 2024-12-11 22:58:44]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]