id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

chanr@sfusd.edu pythonfunctionsfive > getCostOfCoffee
prev  |  next  |  chance

Write a function named getCostOfCoffee() that has a parameters named numberOfCoffees and pricePerCoffee. Given this information, the function returns the total cost of the coffee order. This is not a simple multiplication of cost and quantity, however, because the coffee shop has an offer where you get one free coffee for every eight coffees you buy.
For example, buying eight coffees for $2.50 each costs $20 (or 8 × 2.5). But buying nine coffees also costs $20, since the first eight makes the ninth coffee free. Buying ten coffees calculates as follows: $20 for the first eight coffees, a free ninth coffee, and $2.50 for the tenth coffee for a total of $22.50.


getCostOfCoffee(7, 2.5) → 17.5
getCostOfCoffee(8, 2.5) → 20.0
getCostOfCoffee(9, 2.5) → 20.0

...Save, Compile, Run (ctrl-enter)

def getCostOfCoffee(numberOfCoffees, pricePerCoffee):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 201 Post-solution available

Copyright Nick Parlante 2017 - privacy