某家具工厂需要批量计算板材的体积,使用了下面这个类:class Board: def __init__(self, l, w, h): self.l = l self.w = w self.h = h 如果要增加一个方法get_volume()返回体积,以下定义最合适的是?( )
A:def get_volume(l, w, h): return l * w * h
B:def get_volume(): return self.l * self.w * self.h
C:def get_volume(self): return self.l * self.w * self.h
D:def get_volume(self, l, w, h): return l * w * h
正确答案:C
试卷来源:202603 青少年软件编程等级考试Python六级真题