-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution14.py
More file actions
34 lines (27 loc) · 1006 Bytes
/
solution14.py
File metadata and controls
34 lines (27 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""# ex.14
You want to buy something from Amazon. The seller charges different prices for shipping cost based on location.
For US it's 5$, for Europe it's 7$, for Canada it's 3$, for other places it's 9$
Create a program that:
* Reads the cost of the product
* Reads your location
* Print the amount of money you have to pay
* Ouput: "You have to pay 23$, 20$ for the product and 3$ for shipping cost"
"""
def total_cost(item_cost, location):
if location == "US":
shipping_fee = "$5"
total_due = item_cost + 5
elif location == "Europe":
shipping_fee = "$7"
total_due = item_cost + 7
elif location == "Canada":
shipping_fee = "$3"
total_due = item_cost + 3
else:
shipping_fee = "$9"
total_due = item_cost + 9
return total_due, shipping_fee
item_costs = 10
place = "US"
pay, shipping = total_cost(item_costs, place)
print(f"You have to pay ${pay}, {item_costs}$ for the product and {shipping} for shipping cost")