Last active
October 19, 2016 19:51
-
-
Save ProfessorLogout/303d03c07703a365b3ccfadbfe7e48a2 to your computer and use it in GitHub Desktop.
Gives you the lower degree between to pointers on a circular watch based on a HH:MM entrys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import time as t | |
DEGREE_MIN = 6 | |
DEGREE_HOUR = 30 | |
while True: | |
time = input("Please enter a timestamp!\nformatted like -> HH:MM\n>").split(":") | |
try: | |
mytime = t(hour=int(time[0]),minute=int(time[1])) | |
except: | |
print("Congratulations!\nYou are to dumb to enter a valid timestamp!\Retry it!") | |
time[1] = mytime.minute | |
time[0] = mytime.hour | |
if time[0] > 12: | |
time[0] = time[0] - 12 | |
time[0] = time[0] * DEGREE_HOUR + DEGREE_HOUR / DEGREE_MIN | |
time[1] = time[1] * DEGREE_MIN | |
if time[1] - time[0] > 0: | |
zeigerabstand = time[1] - time[0] | |
else: | |
zeigerabstand = time[0] - time[1] | |
if zeigerabstand > 180: | |
zeigerabstand = 360 - zeigerabstand | |
print("Lower angel between pointers:",zeigerabstand,"Degrees",sep=" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment