Daily Calorie Intake

apple

Did You Know?

Keeping a healthy lifestyle consists of adapting our daily food intake with our level of physical activities. The calories we intake (by eating food) has to roughly match the calories we burn throughout the day.

Your Challenge


For this challenge you are going to write a Python program that asks the user for their gender (Male of Female), their lifestyle (Sedentary, Moderately Active, Active) and their age.
The program will then tell them what their daily calorie intake should be.

The program should make use of the following table of data:


GenderAge (years)SedentaryModerately ActiveActive
Female2 to 3100012001400
4 to 8120014001800
9 to 13160019002200
14 to 18180021002400
19 to 30200022002400
31 to 50180020002200
51+160019002200
Male2 to 3100012001400
4 to 8140017002000
9 to 13180022002600
14 to 18220027003200
19 to 30240027003000
31 to 50220026003000
51+200024002800

Learning Objectives


By Completing this learning challenge you will use:

  • Nested If Statements,
  • Comparison Operators such as ==, !=, <, <=, >, >=,
  • Boolean Operators: AND or OR.

Tip:


Complete this task progressively using the following 3 steps:

Step 1:

    Start by asking the end-user for their gender.
    If their gender is Male display your calorie intake is around 2400 calories for a man, or 2000 for a woman. If you need a reminder on how to use the input, if and print instructions in python check this page.

Step 2:

    Add an input at the beginning to ask the user for their age (in years). Convert this input to an integer using the int() function. Use nested if to display the right daily calorie intake based on both the gender and the age. (Use the data from the first column, “sedentary” at this stage.)

    Remember when using nested if statements to indent your code accordingly.

Step 3:

    You can now use a third question to ask the user if they are “S” – Sedentary, “M” – Moderately Active, “A” Active.
    Use a third level of indentation/nesting to complete this challenge using all the data from the given table.

Your Code:


Extension Task:


Ask the user how many calories they have eaten so far (this day) and return the number of calories they can still have till the end of the day to match their recommended daily calorie intake.

Review…


Complete this fill in the gaps activity to check whether you can use the right computing terminology.

Did you like this challenge?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,