CODING LANGUAGES I’VE WORKED WITH
caloric_needs_calculator.py This is a script that calculates your daily caloric needs.
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 8 18:44:30 2020
@author: jandj
"""
##
# This is a Python utility script for Spatial Data Discovery, created by Jonah Casale.
# This script calculates your caloric needs based on height, age, sex, and weight.
##
# Imports here
import argparse
# First determine the person's BMR using Harris-Benedict formula.
# Adult male: 66 + (6.3 x body weight in lbs.) + (12.9 x height in inches) - (6.8 x age in years) = BMR
# Adult female: 655 + (4.3 x weight in lbs.) + (4.7 x height in inches) - (4.7 x age in years) = BMR
= input("Please enter your body weight (lbs.): \n")
userBodyWeight = input("Please enter your height (in inches): \n")
userHeight = input("Please enter your sex: type M for male or F for female: \n")
userSex = input("Please enter your age (in years): \n")
userAge # Cast all the numerical inputs to floats.
= float(userBodyWeight)
userBodyWeight = float(userHeight)
userHeight = float(userAge)
userAge # Check if user's inputs are positive, not negative. If negative, print error message.
# Otherwise, program continues.
if (float(userBodyWeight) < 0) or (float(userHeight) < 0) or (float(userAge) < 0) :
print("One of your answers is a negative number. Please enter positive numbers only. Try again.")
else :
# Determine formula based on sex to calculate BMR.
if (userSex == "M") or (userSex == "m") :
= 66 + (6.3 * userBodyWeight) + (12.9 * userHeight) - (6.8 * userAge)
userBMR if (userSex == "F") or (userSex == "f") :
= 655 + (4.3 * userBodyWeight) + (4.7 * userHeight) - (4.7 * userAge)
userBMR
# Now ask for user's activity level.
print("Would you say that you are: \n")
print("sedentary (little or no exercise at all)")
print("lightly_active (light exercise/sports 1-3 days/week)")
print("moderately_active (moderate exercise/sports 3-5 days/week)")
print("very_active (hard exercise/sports 6-7 days a week)")
print("extremely_active (we're talking elite athletes here!)")
= input("Please type your activity level (sedentary, lightly_active, moderately_active, very_active, extremely_active): \n")
activityLevel
if activityLevel == "sedentary" :
= userBMR * 1.2
caloricNeeds elif activityLevel == "lightly_active" :
= userBMR * 1.375
caloricNeeds elif activityLevel == "moderately_active" :
= userBMR * 1.55
caloricNeeds elif activityLevel == "very_active" :
== userBMR * 1.725
caloricNeeds elif activityLevel == "extremely_active" :
== userBMR * 1.9
caloricNeeds else :
print("You inputed your activity level incorrectly. Start over and try again.")
print(" ")
print("Based on the information you have inputted, your APPROXIMATE caloric needs are " + str(caloricNeeds) + " calories per day to maintain your current weight.")
= argparse.ArgumentParser(description="Calculates your daily caloric needs") p