-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmeal.py
More file actions
25 lines (23 loc) · 715 Bytes
/
meal.py
File metadata and controls
25 lines (23 loc) · 715 Bytes
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
def main():
time = input("What time is it? ")
time = convert(time)
if 7 <= time <= 8:
print("breakfast time")
elif 12 <= time <= 13:
print("lunch time")
elif 18 <= time <= 19:
print("dinner time")
def convert(time):
if time.endswith(" a.m."):
time = time.split(' a.m.')
time = time[0].split(':')
return round(int(time[0]) + int(time[1])/60, 2)
elif time.endswith(" p.m."):
time = time.split(' p.m.')
time = time[0].split(':')
return round(12 + int(time[0]) + int(time[1])/60, 2)
else:
time = time.split(":")
return round(int(time[0]) + int(time[1])/60, 2)
if __name__ == "__main__":
main()