Calculate Caloric Intake   Learning Objective: In this lab, you will practice Functions and test functions Lists Printing If statements Instructions: Main Idea The Basal Metabolic Rate (BMR) is the amount of energy (calories) your body needs while resting. This accounts for about 60 to 70 percent of calories burned in a day. In general, men have a higher BMR than women. One of the most accurate methods of estimating your basal metabolic rate is the Harris-Benedict formula: Adult_Male_BMR = 66 + (6.3 x bodyweight in lbs.) + (12.9 x height in inches) - (6.8 x age in years) Adult_Female_BMR = 655 + (4.3 x weight in lbs.) + (4.7 x height in inches) - (4.7 x age in years) In this lab, you will be given the function calculate_calorie_intake and you will be required to write the body of the test functions test_calculate_calorie_intake_negative, test_calculate_calorie_intake_1, test_calculate_calorie_intake_3. In these functions, you will write function calls to calculate_calorie_intake and will check if the result matches the expected return or not. Steps In function test_calculate_calorie_intake_negative: call calculate_calorie_intake with BMR = 705 and activity_index= -1 If the expected result (should be zero) is equal to the result (the return of the function call), print: Test Passed. Otherwise, print: Test failed! Expected  ---> Result  In test_calculate_calorie_intake_1: call calculate_calorie_intake with BMR = 1076 and activity_index= 1 If the expected result (should be1478 ) is equal to the result (the return of the function call), print: Test Passed. Otherwise, print: Test failed! Expected  ---> Result  In test_calculate_calorie_intake_3: call calculate_calorie_intake with BMR = 1068 and activity_index= 3 If the expected result (should be 1655.4) is equal to the result (the return of the function call), print: Test Passed. Otherwise, print: Test failed! Expected  ---> Result     This is my wrong code below:     def calculate_calorie_intake(BMR , activity_index):     if activity_index == 1:         return BMR * 1.2     elif activity_index == 2:         return BMR * 1.375     elif activity_index == 3:         return BMR * 1.55     elif activity_index == 4:         return BMR * 1.725     elif activity_index == 5:         return BMR * 1.9     else:         return 0 def test_calculate_calorie_intake_negative():     print("Test: calculate_calorie_intake: activity index = -1")     #Write your code here     pass def test_calculate_calorie_intake_1():     print("Test: calculate_calorie_intake: activity index = 1")     #Write your code here     pass def test_calculate_calorie_intake_3():     print("Test: calculate_calorie_intake: activity index = 3")     #write your code here     pass if __name__ == "__main__":     test_calculate_calorie_intake_negative()     test_calculate_calorie_intake_1()     test_calculate_calorie_intake_3()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Calculate Caloric Intake

 

Learning Objective:

In this lab, you will practice

  1. Functions and test functions
  2. Lists
  3. Printing
  4. If statements

Instructions:

Main Idea

The Basal Metabolic Rate (BMR) is the amount of energy (calories) your body needs while resting. This accounts for about 60 to 70 percent of calories burned in a day. In general, men have a higher BMR than women. One of the most accurate methods of estimating your basal metabolic rate is the Harris-Benedict formula:

Adult_Male_BMR = 66 + (6.3 x bodyweight in lbs.) + (12.9 x height in inches) - (6.8 x age in years)

Adult_Female_BMR = 655 + (4.3 x weight in lbs.) + (4.7 x height in inches) - (4.7 x age in years)

In this lab, you will be given the function calculate_calorie_intake and you will be required to write the body of the test functions test_calculate_calorie_intake_negative, test_calculate_calorie_intake_1, test_calculate_calorie_intake_3. In these functions, you will write function calls to calculate_calorie_intake and will check if the result matches the expected return or not.

Steps

  1. In function test_calculate_calorie_intake_negative:

    • call calculate_calorie_intake with BMR = 705 and activity_index= -1
    • If the expected result (should be zero) is equal to the result (the return of the function call), print: Test Passed.
    • Otherwise, print: Test failed! Expected <expected> ---> Result <result>
  2. In test_calculate_calorie_intake_1:

    • call calculate_calorie_intake with BMR = 1076 and activity_index= 1
    • If the expected result (should be1478 ) is equal to the result (the return of the function call), print: Test Passed.
    • Otherwise, print: Test failed! Expected <expected> ---> Result <result>
  3. In test_calculate_calorie_intake_3:

    • call calculate_calorie_intake with BMR = 1068 and activity_index= 3
    • If the expected result (should be 1655.4) is equal to the result (the return of the function call), print: Test Passed.
    • Otherwise, print: Test failed! Expected <expected> ---> Result <result>

 

 This is my wrong code below:

 

 

def calculate_calorie_intake(BMR , activity_index):
    if activity_index == 1:
        return BMR * 1.2
    elif activity_index == 2:
        return BMR * 1.375
    elif activity_index == 3:
        return BMR * 1.55
    elif activity_index == 4:
        return BMR * 1.725
    elif activity_index == 5:
        return BMR * 1.9
    else:
        return 0

def test_calculate_calorie_intake_negative():
    print("Test: calculate_calorie_intake: activity index = -1")
    #Write your code here
    pass

def test_calculate_calorie_intake_1():
    print("Test: calculate_calorie_intake: activity index = 1")
    #Write your code here
    pass

def test_calculate_calorie_intake_3():
    print("Test: calculate_calorie_intake: activity index = 3")
    #write your code here
    pass

if __name__ == "__main__":
    test_calculate_calorie_intake_negative()
    test_calculate_calorie_intake_1()
    test_calculate_calorie_intake_3()

1: Compare output a
Output differs. See highlights below.
Special character legend
Test: calculate_calorie_intake: activity index = -1
Your output
Test: calculate_calorie_intake: activity index = 1
Test: calculate_calorie_intake: activity index = 3
Test: calculate calorie intake: activity index = -1
Test Passede
Test: calculate_calorie_intake: activity index = 1
Expected output
Test failed! Expected 1478 ---> Result 1291.24
Test: calculate calorie intake: activity index = 3
Test Passedd
Transcribed Image Text:1: Compare output a Output differs. See highlights below. Special character legend Test: calculate_calorie_intake: activity index = -1 Your output Test: calculate_calorie_intake: activity index = 1 Test: calculate_calorie_intake: activity index = 3 Test: calculate calorie intake: activity index = -1 Test Passede Test: calculate_calorie_intake: activity index = 1 Expected output Test failed! Expected 1478 ---> Result 1291.24 Test: calculate calorie intake: activity index = 3 Test Passedd
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education