80.9k views
0 votes
PARTICIPATION ACTIVITY 4.1.13: Hierarchical function calls. Complete the calc_pizza_calories_per_slice() function to calculate the calories for a single slice of pizza. A calc_pizza_calories() function returns a pizza's total calories given the pizza diameter passed as an argument. A calc_num_pizza_slices() function returns the number of slices in a pizza given the pizza diameter passed as an argument def calc pizza_calories_per_slice(pizza_diameter): total_calories = calories_per_slice = return calories_per_slice 1) Type the expression for placeholder_A to calculate the total calories for a pizza with diameter pizza diameter Incorrect calc_pizza_calories(?) total_calories = pizzaCalories(pizzaDiameter); Check Show answer 2) Type the expression for placeholder_B to calculate the calories per slice. Incorrect total calories/? calories_per_slice = total calories / pizza Slices(pizza diameter) Check Show answer Feedba

User Youniteus
by
8.3k points

1 Answer

4 votes

Placeholder expressions:

Placeholder A: calc_pizza_calories(pizza_diameter)

Placeholder B: total_calories / calc_num_pizza_slices(pizza_diameter)

How to explain

Placeholder A: calc_pizza_calories(pizza_diameter) calls the calc_pizza_calories function with the pizza_diameter argument, retrieving the total calorie count for the entire pizza.

Placeholder B: total_calories / calc_num_pizza_slices(pizza_diameter) divides the total calories by the number of slices in the pizza (calculated by calc_num_pizza_slices(pizza_diameter)) to obtain the calorie count per slice.

User Geoffrey Irving
by
8.1k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.