Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- print "*******Welcome to the MACRONUTRIENT CALCULATOR********"
- calorie_deficit = float(input("Enter your calorie deficit: "))
- Percent_protein = float(input("Percentage of Protein: "))
- Percent_carb = float(input("Percent of Carbohydrates: "))
- Percent_fat = float(input("Percentage of Fats: "))
- Macro_dict = {'Protein': Percent_protein, 'Carbohydrate': Percent_carb, 'Fats': Percent_fat}
- Macro_sum = Percent_protein + Percent_carb + Percent_fat
- Total_Macro_Check(Macro_sum)
- Macro_percentage_to_calorie(calorie_deficit, Percent_protein, Percent_carb, Percent_fat)
- def Total_Macro_Check(total_val):
- if total_val > 100:
- print "Total percentages surpassed 100! Please reenter percentages."
- main()
- if total_val < 100:
- print "Total precentages is less than 100! Please reenter precentages."
- main()
- def Macro_percentage_to_calorie(calorie, protein, carb, fat):
- """ calories in 1 gram of P/C/F """
- cal_in_protein = 4
- cal_in_fat = 9
- cal_in_carb = 4
- """ multiple percentages with calories"""
- mult_protein = protein/100.0
- mult_fat = fat/100.0
- mult_carb = carb/100.0
- calories_of_protein = calorie*mult_protein
- grams_of_protein = calories_of_protein/cal_in_protein
- print "You must eat " + str(calories_of_protein) + " calories of protein which is equivalent to " + str(grams_of_protein) + " grams of protein."
- calories_of_fat = calorie*mult_fat
- grams_of_fat = calories_of_fat/cal_in_fat
- print "You must eat " + str(calories_of_fat) + " calories of fat which is equivalent to " + str(grams_of_fat) + " grams of fat."
- calories_of_carb = calorie*mult_carb
- grams_of_carb = calories_of_carb/cal_in_fat
- print "You must eat " + str(calories_of_carb) + " calories of carbohydrates which is equivalent to " + str(grams_of_carb) + " grams of carbohydrates."
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment