-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Section 5.14 - Exercise 1 #18
Comments
import time
epoch = time.time()
seconds_in_a_day = 24 * 60 * 60
seconds_in_an_hour = 60 * 60
seconds_in_a_minute = 60
days = epoch // seconds_in_a_day
hours = (epoch % seconds_in_a_day) // seconds_in_an_hour + 8
minutes = (epoch % seconds_in_a_day) % seconds_in_an_hour // seconds_in_a_minute
seconds = (epoch % seconds_in_a_day) % seconds_in_an_hour % seconds_in_a_minute
print("%s: %s: %s: %s" %(days, hours, minutes, seconds))
print("Beijing Current time is %d: %d: %d: %d" %(days, hours, minutes, seconds")) |
Looks like the extra closing quote is not needed on final print statement. |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think asking a student to convert the epoch into time of day might be a little too complicated for Exercise 1 of the chapter. Dates aren't the easiest subject to deal with this early into python. I was trying to use ThinkPython 2 to tutor a student today and found it to be far too advanced having just learned conditionals and floor division in the same chapter.
The text was updated successfully, but these errors were encountered: