logo

Crowdly

There are three primary macronutrients: Carbohydrates (C): 4 Cal/g Proteins (P...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

There are three primary

macronutrients:

  • Carbohydrates (C): 4 Cal/g
  • Proteins (P): 5 Cal/g
  • Fats (F): 9 Cal/g

Fill in the blanks in the template files below so that together the files complete the following tasks:

1. Create a user-defined function, food

, that takes the amount of C, P, and F (in grams) as inputs, and

returns the total energy intake in both calories (Cal) and kilojoules (kJ).

Note that 1 Cal = 4.186 kJ. Assume that this function has been created in a user-defined module,

food_func.

2. Use this function to determine the energy intake for the following meals and display the results in a clear and readable format.

  • KFC snack plate: C = 55 g, P = 0.17 kg, F = 123 g
  • Dozen KK donuts: F = 131 g, P = 22 g, C =

    0.275 kg

  • A 12-inch falafel sandwich: P = 14.7 g, F = 12.6 g, C = 1546.9 mg

food_func.py template:

    """

    Calculates the energy intake of food based on information about the food's macronutrients

    Args:

        C:

        P:

        F:

    Returns:

        energy_intake_C:

        energy_intake_kJ:

    """

    energy_intake_C = 4*C + 5*P + 9*F

    energy_intake_kJ = energy_intake_C*4.186

    return

food_task.py template:

from food_func import food

KFC_energy_C, KFC_energy_kJ =

print(f"KFC snack plate: {KFC_energy_C:,.0f} Cal & {KFC_energy_kJ:,.0f} kJ")

KK_donuts_energy_C, KK_donuts_energy_kJ =

print(f"KK donuts: {KK_donuts_energy_C:,.0f} Cal & {KK_donuts_energy_kJ:,.0f} kJ")

falafel_energy_C, falafel_energy_kJ = 

print(f"Falafel sandwich: {falafel_energy_C:,.0f} Cal & {falafel_energy_kJ:,.0f} kJ")

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!