Skip to content

Instantly share code, notes, and snippets.

@jjlumagbas
Last active September 1, 2016 02:17
Show Gist options
  • Save jjlumagbas/777a2290663756a78dd031bc0da72f8a to your computer and use it in GitHub Desktop.
Save jjlumagbas/777a2290663756a78dd031bc0da72f8a to your computer and use it in GitHub Desktop.
# The Kapehan coffee shop sells coffee
# beans at P850 per kilo plus the
# cost of shipping. Each order ships
# for P185 per kilo + P250 fixed cost
# per shipment for overhead.
# Write a function that calculates the
# cost of an order. 

# def order_cost(kilos):
# """
# (number) -> number
# Calculates the cost of an order, including
# shipping, given the number of kilos ordered
# """
# return 0
# def order_cost(kilos):
# """
# (number) -> number
# Calculates the cost of an order, including
# shipping, given the number of kilos ordered
# """
# return ... kilos 850 185 250
def order_cost(kilos):
"""
(number) -> number
Calculates the cost of an order, including
shipping, given the number of kilos ordered
"""
return (850 * kilos) + (185 * kilos) + 250
print(order_cost(1)) # expect 1285
print(order_cost(2)) # expect 2320 = (850 * 2) + (185 * 2) + 250
print(order_cost(3)) # expect 3355 = (850 * 3) + (185 * 3) + 250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment