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 FUbaer
def sun_angle(time):
'''
Split the time string into hours and minutes.
One hour equals 15°, one minute corresponds to 0.25°.
Calculate the angles and sum them.
'''
angle = (int(time.split(":")[0])-6) * 15 + int(time.split(":")[1]) * 0.25
if angle < 0 or angle > 180: # we delete the negative angles
return "I don't see the sun!"
return angle
if __name__ == '__main__':
print("Example:")
print(sun_angle("17:09"))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert sun_angle("12:15") == 15
assert sun_angle("01:23") == "I don't see the sun!"
print("Coding complete? Click 'Check' to earn cool rewards!")
Feb. 7, 2020