Untitled
By: a guest | Mar 20th, 2010 | Syntax:
None | Size: 1.90 KB | Hits: 57 | Expires: Never
#!/usr/bin/python
#{filename}
import math
# takes in hours and gives day # and hour in 24 hour time (7 days/week)
def hoursTo24DaysHours (hours):
return (int(math.floor((hours / 24))) + 1,(hours % 24))
# takes in hours and gives day # and hour in 28 hour time (6 days/week)
def hoursTo28DaysHours (hours):
return (int(math.floor((hours / 28)) + 1,(hours % 28)))
# takes in a day # and hour in 28 hour time and returns day # and hour in 24 hour time
def daysHours28To24 (day, dayHours):
return hoursTo24DaysHours((day * 28) + dayHours)
# takes in a day # and hour in 24 hour time and returns day # and hour in 28 hour time
def daysHours24To28 (day, dayHours):
return hoursTo28DaysHours((day * 24) + dayHours)
print ("choose the day and time to set latest wake condition")
print ("(1) Monday")
print ("(2) Tuesday")
print ("(3) Wednesday")
print ("(4) Thursday")
print ("(5) Friday")
print ("(6) Saturday")
print ("(7) Sunday")
dayToWakeLatest = int(input("select day:"))
timeToWakeLatest = int(input("select time (24 hour time, enter hour #:"))
weekHourOfLatestWake = (((dayToWakeLatest - 1) * 24) + timeToWakeLatest)
hoursOfSleep = int(input("hours of sleep per 28 hour cycle:"))
print ("week hour of latest wake condition = ", weekHourOfLatestWake)
print ("6 day week timetable")
for day in range(1,8):
wakeHour = (weekHourOfLatestWake - (28 * (dayToWakeLatest - day)))
wakeTime = hoursTo24DaysHours(wakeHour)
wakeDay = wakeTime[0]
if (wakeDay == 0):
wakeDay = 7
elif (wakeDay == 8):
wakeDay = 1
wakeHr = wakeTime[1]
sleepTime = hoursTo24DaysHours(wakeHour + (28 - hoursOfSleep))
sleepDay = sleepTime[0]
if (sleepDay == 0):
sleepDay = 7
elif (sleepDay == 8):
sleepDay = 1
sleepHr = sleepTime[1]
print ("day ", day)
print ("wakeHour = ", wakeHour)
print ("wake at (",wakeDay,", ",wakeHr,")")
print ("sleep at (",sleepDay,", ",sleepHr,")")
print("\n")