samedi 28 mai 2016

if elif else program python

Shipping charges for an online orders are based on the value of the order and the shipping weight. Shipping is free if the value is over $100. Orders under $100 incur shipping charges as follows: Over 40 lbs: $1.09 per lb. Over 20 lbs: $0.99 per lb. Equal to or Under 20 lbs: $0.89 per lb. I need to write a python program that prompts the user to enter both the value and weight of an order, then displays the required shipping charges. But if the order value is $100 or more, weight is irrelevant and your program should not ask for it.

SO far I have figure out the coding for the shipping not sure about the other parts.

#Have user enter weight of order
weight = int(input('Enter the weight of your order:'))

#Determine shipping cost
if weight >= 40:
    total = weight * 1.09
elif weight >= 20:
    total = weight * 0.99
elif weight <=20:
    total = weight * 0.89

Thank you for your help!

Aucun commentaire:

Enregistrer un commentaire