Created
November 17, 2016 23:35
-
-
Save MorkHub/32eb65038ffbe32801ab5b9197fc8482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exercise_02 (): | |
print(" Exercise 02 - Shipping Charges Calculator") | |
weight = input(" Enter the mass of the package (kg): ",type=float) | |
while not (weight > 0 and weight <= 30): | |
weight = input(" Invalid mass. Try again: ",type=float) | |
method = input(" Enter shipping method (A|S): ",type=str).upper() | |
while not (method in ['A','S']): | |
method = input(" Invalid shipping method: ",type=str) | |
cost = 0 | |
if weight < 2.5: | |
cost = 4.95 | |
elif weight >= 2.5 and weight < 10: | |
cost = 8.95 | |
elif weight >= 10 and weight < 30: | |
cost = 15.95 | |
elif weight >= 30: | |
cost = 22.95 | |
if method == 'A': | |
cost = cost * 1.5 | |
cost = round(cost,2) | |
print(" This package will cost $%s" % cost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment