-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalorie-count
72 lines (59 loc) · 1.79 KB
/
calorie-count
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
###########################
# calorie-count #
# written by James Masuda #
# v 1.0 : 08.01.2016 #
###########################
from datetime import datetime
import time
import sys
print (30 * '-')
print " C A L O R I E - C O U N T "
print (30 * '-')
print ""
print ""
total_users = int(raw_input("How many users in total? "))
# users = {
# name: {
# goal : 2000,
# meals : []
# }
# }
users = {}
meals = ["breakfast", "lunch", "dinner", "snacks"]
for _ in range(total_users) :
name = raw_input("Enter your name here: ")
users[name] = {}
goal = int(raw_input("Okay %s, what is your target calorie goal? " % (name)))
if goal <= 1500 and goal >= 501:
print "Awesome goal!"
elif goal <= 500:
print "You are INSANE!"
elif goal >= 2000:
print "I think you can do better than that."
users[name]["goal"] = goal
users[name]["meals"] = []
for meal in meals :
if meal == "snacks" :
q = raw_input("Did you eat any snacks today? y/n: ")
if not(q == 'y' or q == 'yes') :
continue
cals = int(raw_input("Enter %s calories: " % meal))
users[name]["meals"].append(cals)
users[name]["total"] = sum(users[name]["meals"])
print "Awesome! Let me tally everything up and see what it looks like!"
#This is just for fun
def math(s):
for c in s:
sys.stdout.write( '%s' %c )
sys.stdout.flush()
time.sleep(0.25)
math(" ..m..a..t..h..")
now = datetime.now()
print ""
print " %s/%s/%s " % (now.month, now.day, now.year)
print " ------------------"
print "Name Cals"
print " ------------------"
for name in users :
print "{} {}".format(name, users[name]["total"])