Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

XYZ = 127 So, 1.01XYZ = 1.01127 estimating total calories in order to assist users in managing their intake of calories. You should read the

XYZ = 127

So, 1.01XYZ = 1.01127

image text in transcribedimage text in transcribed

estimating total calories in order to assist users in managing their intake of calories. You should read the question all the way through before you start, to make sure that you understand the scenario. Background to the problem: A nutritional app assists users in assessing their dietary habits. For the purpose of evaluation, the app asks the members to report how many fat grams and how many carbohydrate grams they consume per day. To help users manage their calorie budgets more effectively, the app calculates the total calories derived from fat and carbohydrates, rounded to the nearest calorie. The problem: The purpose of this question is to write a program that will perform these nutritional calculations. Specifically, you will produce an estimate of the total calories as follows: calestimated=1.01XYZcaltotal=1.01XYZ(calfat+calcarb) The number of calories resulting from the fat are calculated by multiplying the fat grams by 9 . calfat=fatgr9 Similarly, the number of calories that result from the carbohydrates are calculated as the carbohydrates grams multiplied by 4 . calcarb=carbgr4 Your individual number is tied to the total calories so that there is some margin of error in the estimates. For example, if a member reported fatgr=150 of fat and carbgr=300 of carbohydrates on a day and the individual number is 1.01123 then: calestimated=1.01123(1509+3004) calestimated=2579 calories (rounded to the nearest calorie) i. Develop an initial decomposition of the problem using the chevron notation ( > and > ) from the module materials. Include your decomposition in your solution document. ii. Building on your decomposition for part c.i., develop an algorithm for solving the problem. Include this algorithm in your solution document, and also write down your PI and the individual number that you have obtained via Steps 1-3 from your PI. iii. Write a Python function definition following the instructions that are provided below. Save your function in a file called Q4_OUCU.py, where 'OUCU' is your OUCU number. When you have completed your work on this part: - submit the .py file with your function - paste the function definition from your .py file as text (with indentation preserved) into your solution document Instructions for writing the function: - Provide a single Python function that implements the algorithm you wrote for part c.ii. Your function must be a translation of your algorithm from part c.ii., otherwise no marks will be awarded. - The function should have two arguments: one for the fat grams fat gr and one for the carbohydrates grams carb gr . - The function should have one return value for the estimated calories cal estimated, which is an integer. iv. Test the function by calling it with the arguments 150 and 300 in your Python program. Paste the function call and the result as text into your Solution document. You should aim to use only the Python features that are introduced in the module. If you decide to use techniques or language features that TM112 does not cover, you must give a justification for your decisions, otherwise marks will be lost

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ehs 2.0 Revolutionizing The Future Of Safety With Digital Technology

Authors: Tony Mudd

1st Edition

B0CN69B3HW, 979-8867463663

More Books

Students also viewed these Databases questions

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago