Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import os
  2.  
  3. def getCalories(question):
  4. calories = input(question)
  5. if calories.isdigit():
  6. calories = int(calories)
  7. if calories > -1 and calories < 50000:
  8. return calories
  9. else:
  10. print("Invalid amount")
  11. return getCalories(question)
  12. else:
  13. print("Numbers only please")
  14. return getCalories(question)
  15.  
  16. def getAweek():
  17. os.system("clear")
  18. print("Please enter your calories for the last 7 days")
  19. week = []
  20. for i in range(7):
  21. day = getCalories(question = "Day " + str(i+1) + ":")
  22. week.append(day)
  23.  
  24. total = sum(week)
  25. average = int(total / 7)
  26.  
  27. print("\n\nYour total calorie intake for the week:", total)
  28. print("\nYour average calorie intake for the week:", average)
  29.  
  30. if total > 21000:
  31. print("\nYou are eating too many calories. You will get fat!")
  32. elif total < 9000:
  33. print("\nYou are eating far too few calories. You will become anorexic.")
  34. input("Press enter to continue") # pause program until user presses enter.
  35. return week
  36.  
  37. month = [[],[],[],[]] # Create list 4 week's values (empty at the moment!)
  38. def main():
  39. os.system("clear")
  40. print("********* Welcome to the calorie counter **********\n\n")
  41. print("Num\tMon \tTues \tWeds \tThurs \tFri \tSat \tSun \tAvg \tTot ")
  42. count = 1
  43. for week in month:
  44. if len(week) == 7:
  45. print(count, end="\t")
  46. for day in week:
  47. print(day,end="\t")
  48. print(int(sum(week)/7),end="\t")
  49. print(sum(week),end="\n")
  50. else:
  51. print("")
  52. #print(str(count) +"\t" + "\t".join([str(x) for x in week]) + ""\n"
  53. count = count + 1
  54.  
  55. weeknum = int(input("\n\nWhich week would you like to edit the values for? (1,2,3,4)"))
  56. month[weeknum-1] = getAweek()
  57. main() #Run the main loop again
  58.  
  59. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement