Guest User

Untitled

a guest
May 30th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1.  
  2. def main():
  3. print "*******Welcome to the MACRONUTRIENT CALCULATOR********"
  4. calorie_deficit = float(input("Enter your calorie deficit: "))
  5. Percent_protein = float(input("Percentage of Protein: "))
  6. Percent_carb = float(input("Percent of Carbohydrates: "))
  7. Percent_fat = float(input("Percentage of Fats: "))
  8. Macro_dict = {'Protein': Percent_protein, 'Carbohydrate': Percent_carb, 'Fats': Percent_fat}
  9. Macro_sum = Percent_protein + Percent_carb + Percent_fat
  10. Total_Macro_Check(Macro_sum)
  11. Macro_percentage_to_calorie(calorie_deficit, Percent_protein, Percent_carb, Percent_fat)
  12.  
  13. def Total_Macro_Check(total_val):
  14. if total_val > 100:
  15. print "Total percentages surpassed 100! Please reenter percentages."
  16. main()
  17. if total_val < 100:
  18. print "Total precentages is less than 100! Please reenter precentages."
  19. main()
  20.  
  21. def Macro_percentage_to_calorie(calorie, protein, carb, fat):
  22. """ calories in 1 gram of P/C/F """
  23. cal_in_protein = 4
  24. cal_in_fat = 9
  25. cal_in_carb = 4
  26.  
  27. """ multiple percentages with calories"""
  28. mult_protein = protein/100.0
  29. mult_fat = fat/100.0
  30. mult_carb = carb/100.0
  31.  
  32. calories_of_protein = calorie*mult_protein
  33. grams_of_protein = calories_of_protein/cal_in_protein
  34. print "You must eat " + str(calories_of_protein) + " calories of protein which is equivalent to " + str(grams_of_protein) + " grams of protein."
  35.  
  36. calories_of_fat = calorie*mult_fat
  37. grams_of_fat = calories_of_fat/cal_in_fat
  38. print "You must eat " + str(calories_of_fat) + " calories of fat which is equivalent to " + str(grams_of_fat) + " grams of fat."
  39.  
  40. calories_of_carb = calorie*mult_carb
  41. grams_of_carb = calories_of_carb/cal_in_fat
  42. print "You must eat " + str(calories_of_carb) + " calories of carbohydrates which is equivalent to " + str(grams_of_carb) + " grams of carbohydrates."
  43.  
  44. if __name__ == "__main__":
  45. main()
Advertisement
Add Comment
Please, Sign In to add comment