In Python code: Write a program to calculate the percentage of fat calories in a food item. Your program should allow the total number of calories in the food item and the number of grams of fat. Validate the input as follows:
- Make sure the number of calories and the number of fat grams are not less than 0.
- There are 9 calories in every gram of fat. The calories from fat must not exceed the total calories in the food item. Make sure that the number of calories entered is not greater than fat grams times 9.
- Tell the user if the item is a low fat food item. A low fat food gets 30% or less of its calories from fat.
- Need to use defensive programming. (All numbers entered are examples)
Example output should look as follows:
How many calories per serving? -240 (user enters this)
Number of calories must not be negative.
How many calories per serving? 240 (user enters this)
How many grams of fat? -5 (user enters this)
Number of grams of fat must not be negative and calories from fat cannot exceed the total calories.
How many grams of fat? 30 (user enters this)
Number of grams of fat must not be negative and calories from fat cannot exceed the total calories.
How many grams of fat? 5 (user enters this)
18.75% of calories from fat. This is a low fat food.
Program:
while(True):
calories = int(input("How many calories per serving? "))
if(calories<0):
print("Number of calories must not be negative.")
else:
break;
while(True):
fat = int(input("How many grams of fat? "))
if(fat<0 or calories<fat*9):
print("Number of grams of fat must not be negative and calories
from fat cannot exceed the total calories.")
else:
break;
percentageCal = ((fat*9)/calories)*100
print(percentageCal,"% of calories from fat.")
if(percentageCal<=30):
print("This is a low fat food.")
else:
print("This is not low fat food.")
Output:

Code screenshot for proper indentation:

In Python code: Write a program to calculate the percentage of fat calories in a food...
Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: Make sure the number of grams and calories is not less than 0. According to nutritionist formulas, the number of calories cannot exceed fat grams x 9. Make sure that the number of calories entered is not greater than fat grams x 9. Once correct data has been entered, the program should calculate and display the percentage of...
Write a Python program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, therefore: Calories from fat = fat grams * 9 The percentage of calories from fat can be calculated as follows: Calories from fat / total calories If the calories from fat are less than 30 percent of the total...
Students are asked to calculate the total fat and saturated fat content of 2 favorite packaged fast food items.Using the calculation table below, you will estimate the total fat and saturated fat contents of each packaged food item. Some food labels already have the percentage calculation completed, which will eliminate the need for completing the calculation. Once you identify the fat content you will then identify what modifications might make the food healthier or an alternative food item that might...
Students are asked to calculate the total fat and saturated fat content of 2 favorite packaged fast food items. Using the calculation table below, you will estimate the total fat and saturated fat contents of each packaged food item. Some food labels already have the percentage calculation completed, which will eliminate the need for completing the calculation. Once you identify the fat content you will then identify what modifications might make the food healthier or an alternative food item that...
L. Collect data from several fast food chains on the number of fat calories and grams of saturated fat in menu items. Record at least 12 ordered pairs of (fat calories, grams of saturated fat) Organize your data in a table. Il. Make a scatter plot of the data on graph paper. Be sure to label the axes and use an appropriate title for the graph. You may wish to use a graphing calculator, spread sheet, or other technology resource...
Nutrition Facts 8 servings per container Serving size 2/3 oup (55g) Amount per serving Calories % Dally Value 10% Total Fat 8g 5% Saluraled Fat 1g Trans Fat 0g 0% Cholesterol Omg Sodium 160mg Total Carbohydrate 37g Dietary Fiber 4g Total Sugars 12g 7% 13% 14% 20% Includes 10g Added Sugars Protein 3g Vitamin D 2mcg 10% 20% Calclum 260mg 45% Iron 8mg 6% Potassium 235mg S Daty Vekue (DV) tets you how much a nutrient in ning of food...
4. A particular food contains only fat, carbohydrates and protein and has a total of 388 Calories. If 40% of the total Calories comes carbohydrates and 25% of the total Calories comes from protein, how many grams of a) carbohydrates b) protein and c) fat are present in this food item?
1. Ingredients
3. Serving size
4. Servings/container
5. Calories/serving
6. Calories from fat
7. % of total kcal from
fat
8. Protein/serving
9. Carbohydrate/serving
10. Sodium
11. Sugars/serving
12. Dietary fiber
Using the attached table complete a comparison of food labels.
What are two different brands of the same food. Then create a
narrative describing their findings to help them make a complete
and thorough comparison.
Being able to interpret food labels is of importance for wise consumerism. In this assignment, you are required to collect food labels of two...
Each pound of fat contains 3500 food calories. When the body
metabolizes food, 80.5% of this energy goes to heat. Suppose you
decide to run without stopping, an activity that produces 1340 W of
metabolic power for a typical person.
Part A) For how many hours must you run to burn up 1 lb of
fat?
Part B) If you followed your planned exercise program, how much
heat would your body produce when you burn up a pound of fat?...
1. A meal of pasta contains 16 grams protein, 80 grams Carb and 8grams fat. a. How many Calories does the meal provide from these energy nutrients? (Remember Calories and kcals are the same thing) ________*___________= ________ kcal protein ________*___________ = ________kcal carb ________*___________ = ________kcal fat Total = _______ kcal b. What percentage of the Calories in the meal comes from each of the energy-yielding nutrients? (this relates to the second part of practice question 2) _____________________ = __________%...