用python语言写出用def‘’’顺丰计价重量取体积重量和真实重量中较大的值作为计价重量其中体积重量kg=长 cm× 宽 cm× 高 cm÷12000现在你要邮寄一个枕头长80cm宽40cm高15cm真实重量是2kg使用函数给出最终的计价重量‘’’
def calculate_weight(length, width, height, real_weight): volume_weight = length * width * height / 12000 charge_weight = max(volume_weight, real_weight) return charge_weight
length = 80 width = 40 height = 15 real_weight = 2 charge_weight = calculate_weight(length, width, height, real_weight) print("The charge weight is:", charge_weight)
原文地址: https://www.cveoy.top/t/topic/0KW 著作权归作者所有。请勿转载和采集!