Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Sun Angle by Bekenow
from typing import Union
def sun_angle(time: str):
time = [int(i) for i in time.split(':')]
degrees_per_minute = int(24*60/360)
total_time_in_min = time[0]*60 + time[1]
if 6 <= time[0] <= 18:
total_time_in_min -= 360
if total_time_in_min > 720:
return "I don't see the sun!"
sun_degree = total_time_in_min / degrees_per_minute
if int(sun_degree) == sun_degree:
return round(sun_degree)
else:
return round(sun_degree, 2)
else:
return "I don't see the sun!"
print("Example:")
print(sun_angle("07:00"))
assert sun_angle("07:00") == 15
assert sun_angle("12:15") == 93.75
print("The mission is done! Click 'Check Solution' to earn rewards!")
Jan. 4, 2023
Comments: