Which expression is correct for the missing condition in the following code segment? The code is intended to calculate the cost of shipping a package, as follows: $5 for packages weighing less than ten pounds, $10 for packages weighing ten pounds or more but less than twenty pounds, and $15 for packages weighing twenty pounds or more.

if weight < 10 :
    shippingCost = 5
elif weight < 20 : 
    shippingCost = 10
else :
    shippingCost = 15

The correct missing condition is 'weight < 20'. This ensures that packages weighing 10 pounds or more, but less than 20 pounds, are correctly assigned a shipping cost of $10.

Python Shipping Cost Calculation: Missing Condition

原文地址: https://www.cveoy.top/t/topic/mSeO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录