Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
sun_angle solution in Clear category for Sun Angle by dannedved
def sun_angle(time):
#replace this for solution
oclock = int(time[:2]) * 60 + int(time[3:])
#The sun rises at 6:00, i. e. 360 minutes after midnight, and sets at 18:00, i. e. 1080 minutes after midnight.
#The sun moves by 0.25 degrees each minute.
return (oclock - 360) / 4 if oclock in range(360, 1081) else "I don't see the sun!"
if __name__ == '__main__':
print("Example:")
print(sun_angle("07:00"))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert sun_angle("07:00") == 15
assert sun_angle("01:23") == "I don't see the sun!"
print("Coding complete? Click 'Check' to earn cool rewards!")
March 16, 2019