Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- def getCalories(question):
- calories = input(question)
- if calories.isdigit():
- calories = int(calories)
- if calories > -1 and calories < 50000:
- return calories
- else:
- print("Invalid amount")
- return getCalories(question)
- else:
- print("Numbers only please")
- return getCalories(question)
- def getAweek():
- os.system("clear")
- print("Please enter your calories for the last 7 days")
- week = []
- for i in range(7):
- day = getCalories(question = "Day " + str(i+1) + ":")
- week.append(day)
- total = sum(week)
- average = int(total / 7)
- print("\n\nYour total calorie intake for the week:", total)
- print("\nYour average calorie intake for the week:", average)
- if total > 21000:
- print("\nYou are eating too many calories. You will get fat!")
- elif total < 9000:
- print("\nYou are eating far too few calories. You will become anorexic.")
- input("Press enter to continue") # pause program until user presses enter.
- return week
- month = [[],[],[],[]] # Create list 4 week's values (empty at the moment!)
- def main():
- os.system("clear")
- print("********* Welcome to the calorie counter **********\n\n")
- print("Num\tMon \tTues \tWeds \tThurs \tFri \tSat \tSun \tAvg \tTot ")
- count = 1
- for week in month:
- if len(week) == 7:
- print(count, end="\t")
- for day in week:
- print(day,end="\t")
- print(int(sum(week)/7),end="\t")
- print(sum(week),end="\n")
- else:
- print("")
- #print(str(count) +"\t" + "\t".join([str(x) for x in week]) + ""\n"
- count = count + 1
- weeknum = int(input("\n\nWhich week would you like to edit the values for? (1,2,3,4)"))
- month[weeknum-1] = getAweek()
- main() #Run the main loop again
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement