Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Clock Angle by gear
degree_hour = 360 / 12
degree_hour_fraction = degree_hour / 60
degree_minute = 360 / 60
def clock_angle(time):
hour, minute = time.split(':')
hour = int(hour) % 12
minute = int(minute)
hour_hand = hour * degree_hour + minute * degree_hour_fraction
minute_hand = minute * degree_minute
degree = abs(hour_hand - minute_hand)
if degree <= 180:
return degree
else:
return 360 - degree
Oct. 4, 2020