def get_pizza_cake_cost(base_diameter, height_per_level):
n = base_diameter
while n > 0:
cost = get_pizza_area(n) * height_per_level * PIZZA_CAKE_COST_PER_CENTIMETRE_CUBED
n = n - 1
return cost
if you look at the shell here, i would like the function to return the sum of those two values
CodePudding user response:
Change the existing line to
cost = get_pizza_area(n) * height_per_level * PIZZA_CAKE_COST_PER_CENTIMETRE_CUBED
def get_pizza_cake_cost(base_diameter, height_per_level):
n = base_diameter
while n > 0:
cost = get_pizza_area(n) * height_per_level * PIZZA_CAKE_COST_PER_CENTIMETRE_CUBED
n = n - 1
return cost
CodePudding user response:
well, it does not necessarily depend on your data type, but it helps depict better, your situation. Example: for an array of ints that represent cost n = 10: ->
sum = 0;
while (n>0){
sum = arr[n];
n -= 1;
}
return sum;