I started learning Python 2 about a week ago, using Codecademy and Stack Overflow answers to help me learn. I wrote a code to calculate the user's free time based on user sleep and work time. It also lets the user decide whether to see percentage of free time. It's not fancy; I never intend to actually use it. It works the way I want it to.
I'm looking for feedback on how I wrote this code. What should I have done differently?
print "The program is operating."
def sleep(time):
sleep_hours = float(raw_input("How many hours do you sleep a night?: "))
return time - sleep_hours
def work(time):
work_hours = float(raw_input("How many hours do you work each weekday?: "))
time -= work_hours
return time
def see_percent():
reply = raw_input("Would you like to know the percent of your waking time is free time? (Y/N): ").lower()
if reply == "y":
print percent_round + "%."
elif reply == "n":
print "Okay"
else:
print "Y/N means enter a 'Y' for yes or a 'N' for no."
time = 24.
time_minus_sleep = sleep(time)
time_minus_work = work(time_minus_sleep)
waking_time = time_minus_sleep
percent_free = str(time_minus_work / waking_time * 100)
percent_round = percent_free[:5]
print""
print "You have %.2f hours of freetime." % time_minus_work
waking_time = time_minus_sleep
print "Of the %.0f hours in a day, you are awake for %.2f of them." % (time, waking_time)