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 i need answer asap thank u You own 100 acres of timberland,with young timber worth...
please i need answer asap thank u You own 100 acres of timberland,with young timber worth 20,000 if logged today this represent 500 cords of wood at $40 per cord. after logging the land can be sold today for 10,000($100 per acre). the opportunity cost of capital is 10%. you have made the following estimates: a) the price of a cord of wood will increase by 5% per year? b) the price of land will increase by 3% per year....
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...
******Please don't use handwriting and i need unique answer ... Thank you Q3: Consider the following...
******Please don't use handwriting and i need unique answer ... Thank you Q3: Consider the following relation: Student-Dept = (Student-ID, Course, SportActivity, Dept-Name, Building) Having following multivalued dependencies:             F ={ Student-ID ®® Course                    Student-ID ®® SportsActivity                      Dept-Name ®® Building } Explain in your own words why the Student-Dept relation is not in 4NF. Then, convert the Student-Dept relation in 4NF. Also, provide the justification for each step you perform during normalization (4NF). Note: The SportActivity here...
******Please don't use handwriting and i need unique answer ... Thank you Q3: Consider the following...
******Please don't use handwriting and i need unique answer ... Thank you Q3: Consider the following relation: Student-Dept = (Student-ID, Course, SportActivity, Dept-Name, Building) Having following multivalued dependencies:             F ={ Student-ID ®® Course                    Student-ID ®® SportsActivity                      Dept-Name ®® Building } Explain in your own words why the Student-Dept relation is not in 4NF. Then, convert the Student-Dept relation in 4NF. Also, provide the justification for each step you perform during normalization (4NF). Note: The SportActivity here...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT