Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> h, m = 12, 0
>>> gap, n = 180, 10
>>>
>>> hm = h*60 + m
>>>
>>> for hm_ in range(hm, hm+gap*(n+1), gap):
h_, m_ = divmod(hm_, 60)
h_ %= 24
print(f"{h_:02d}:{m_:02d} Carrot Time!")
12:00 Carrot Time!
15:00 Carrot Time!
18:00 Carrot Time!
21:00 Carrot Time!
00:00 Carrot Time!
03:00 Carrot Time!
06:00 Carrot Time!
09:00 Carrot Time!
12:00 Carrot Time!
15:00 Carrot Time!
18:00 Carrot Time!
>>> hm_sleep = 22*60
>>> for hm_ in range(hm, hm+gap*(n+1), gap):
if hm_ >= hm_sleep:
print("Emergency!")
break
h_, m_ = divmod(hm_, 60)
print(f"{h_:02d}:{m_:02d} Carrot Time!")
12:00 Carrot Time!
15:00 Carrot Time!
18:00 Carrot Time!
21:00 Carrot Time!
Emergency!
>>> h, m = 9, 20
>>> gap, n = 72, 7
>>> hm = h*60 + m
>>> for hm_ in range(hm, hm+gap*(n+1), gap):
if hm_ >= hm_sleep:
print("Emergency!")
break
h_, m_ = divmod(hm_, 60)
print(f"{h_:02d}:{m_:02d} Carrot Time!")
09:20 Carrot Time!
10:32 Carrot Time!
11:44 Carrot Time!
12:56 Carrot Time!
14:08 Carrot Time!
15:20 Carrot Time!
16:32 Carrot Time!
17:44 Carrot Time!
>>> hm = h*60 + m
>>> for hm_ in range(hm, hm+gap*n, gap):
if hm_ >= hm_sleep:
print("Emergency!")
break
h_, m_ = divmod(hm_, 60)
print(f"{h_:02d}:{m_:02d} Carrot Time!")
09:20 Carrot Time!
10:32 Carrot Time!
11:44 Carrot Time!
12:56 Carrot Time!
14:08 Carrot Time!
15:20 Carrot Time!
16:32 Carrot Time!
© 2024 OneMinuteCode. All rights reserved.