Question

In: Computer Science

use python3 language and need answer ASAP please thank you. The primary sources of calories in...

use python3 language and need answer ASAP please thank you.

The primary sources of calories in food are fat, carbohydrate, and protein. Proteins and carbohydrates have four calories per gram, and fat has nine calories per gram.

For example, on a box of Honey Nut Cheerios, it says that a serving has 1.5 grams of fat, 22 grams of carbohydrates, and 2 grams of protein. That works out to:

    1.5 * 9 + 22 * 4 + 2 * 4 = 109.5

And right there on the box it says that one serving has 110 calories. create a CGI program to compute calories. You need to write a CGI program which can accept the data from the form and print out a report of the calories. The field names your CGI must accept are: food, for the name of the food; carbs, for the amount of carbohydrates; protein, for the amount of protein; and fats, for the amount of fat.

And here are the correct values for some foods you can try your program out on. (These are rounded to integers, but you don't need to do that.)

Honey Nut Cheerios:
      fat grams: 1.5
     carb grams: 22
  protein grams: 2
 total calories: 110

Big Mac:
      fat grams: 29
     carb grams: 46
  protein grams: 25
 total calories: 545

banana:
      fat grams: 0.4
     carb grams: 27
  protein grams: 1.3
 total calories: 117

potato:
      fat grams: 0.2
     carb grams: 37
  protein grams: 4.3
 total calories: 167

Solutions

Expert Solution

food = input("Enter food name: ") #reading the inputs from the user
fat = float(input("Enter amount of fat: "))
carb = float(input("Enter amount of carbohydrates: "))
protein = float(input("Enter amount of protein: "))
calories = fat*9+carb*4+protein*4 #calculating the number of calories
print(f"{food}:\nfat grams: {fat}\ncarb grams: {carb}\nprotein grams: {protein}\ntotal calories: {calories}") #printing the result


Related Solutions

Please answer ASAP, thank you! 1. Please present, analyze, and comment on a (specific or general)...
Please answer ASAP, thank you! 1. Please present, analyze, and comment on a (specific or general) monetary or fiscal policy enacted by the Federal Reserve Bank or by the Federal Government to help our economy by describing the particular context in which that policy was enacted.
*Please answer questions to case study ASAP. Thank you so much! When you think of the...
*Please answer questions to case study ASAP. Thank you so much! When you think of the most sustainable corporations in the world, Bell Canada may not jump to mind. Nonetheless, Corporate Knights listed Bell as one of only eight Canadian companies to make the Global 100 list of sustainable compa- nies for 2011. Bell Canada Enterprises (BCE) was also named byMaclean’s/Jantzi-Sustainalytics as one of Canada’s Top 50 Socially Responsible Corporations. It also made the prestigious FTSE4Good Global Index. It is...
2 MULTIPLE CHOICE. PLEASE ANSWER ASAP. THANK YOU! 28. Based on the following data for the...
2 MULTIPLE CHOICE. PLEASE ANSWER ASAP. THANK YOU! 28. Based on the following data for the current year, what is the inventory turnover (rounded to one decimal place)? Sales on account during year $489,126 Cost of goods sold during year 195,631 Accounts receivable, beginning of year 42,096 Accounts receivable, end of year 51,765 Inventory, beginning of year 33,834 Inventory, end of year 41,634 a.4.2 b.13 c.18.1 d.5.2 29. Use this information for Kellman Company to answer the question that follow....
MULTIPLE CHOICE PLEASE ANSWER ASAP. THANK YOU. 8. A company with working capital of $375,551 and...
MULTIPLE CHOICE PLEASE ANSWER ASAP. THANK YOU. 8. A company with working capital of $375,551 and a current ratio of 3.2 pays a $82,906 short-term liability. The amount of working capital immediately after payment is a.$551,149 b.$463,350 c.$375,551 d.$87,799 11. Assume the following sales data for a company: Current year $758,619 Preceding year 520,482 What is the percentage increase in sales from the preceding year to the current year (rounded to one decimal place)? a.31.4% b.14.4% c.77.1% d.45.8% 12. Cash...
Need this ASAP, I will thumbs up! Please show work, thank you! Jerry needs to plan...
Need this ASAP, I will thumbs up! Please show work, thank you! Jerry needs to plan for his weekend activity. He may or may not go to play tennis, depending on his friends’ availability. If both Andrew and Bob are going, then Jerry will go with them. Or, if Charlie will go, then Jerry will also go with him. Otherwise, Jerry will not go to play tennis. Please design a logic circuit that makes the decision for Jerry automatically based...
Can you guys answer this question for me please, need it asap!!! Please explain the difference...
Can you guys answer this question for me please, need it asap!!! Please explain the difference between systematic and unsystematic risk. In doing so, provide 4 examples of each type of risk. ( around ~200 words)
. NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE NEED NEW ANSWER ASAP / ANSWER...
. NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE NEED NEW ANSWER ASAP / ANSWER NEVER USED BEFORE Explain horizontal and vertical analysis. Do some research .explain why these methods are used. What can we learn from horizontal and vertical analysis statements? How can results vary compared to other corporations and why can ratios better than using dollars? ANSWER THROUGHLY 1 page *** IN PARAGRAPGH FORM PLEASE NOT BULLET POINTS COPY AND PASTE Answer in paragraphs, and no picture...
Hi guys, ASAP please answer the question thank you so much!! A cyclist travelling at 8.0...
Hi guys, ASAP please answer the question thank you so much!! A cyclist travelling at 8.0 m/s is rounding a corner of radius 20 m on a flat road by leaning into the curve at an angle x with respect to the vertical. the coefficient of static friction between the tyres and the road is 0.80 and the rims and tyres are of negligible mass in comparison to the mass of the cycle and rider. 1. draw a diagram explicitly...
MULTIPLE CHOICE. PLEASE ANSWER ASAP. THANK YOU! 17. Sales for the year were $588,096. Accounts receivable...
MULTIPLE CHOICE. PLEASE ANSWER ASAP. THANK YOU! 17. Sales for the year were $588,096. Accounts receivable were $98,761 and $77,731 at the beginning and end of the year, respectively. Cash received from customers to be reported on the statement of cash flows using the direct method is a.$630,156 b.$609,126 c.$686,857 d.$588,096 23. A building with a book value of $46,754 is sold for $59,053 cash. Using the indirect method, this transaction should be shown on the statement of cash flows...
used in python3 please add comment , thank you Shopping Bag: Assume the user has a...
used in python3 please add comment , thank you Shopping Bag: Assume the user has a bunch of purchases they would like to make. They enter the price of each item, and the quantity and they want to add it to their cart. They tell us if they have more items to purchase, and if they do, we repeat getting the data and add the cost to the shopping bag. When they're done, we display the total. We will not...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT