Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Datetime module solution in Clear category for Sun Angle by ChromeBrainer
import datetime
def sun_angle(time):
#replace this for solution
start=datetime.datetime.strptime("06:00","%H:%M")
end=datetime.datetime.strptime("18:00","%H:%M")
time=datetime.datetime.strptime(time,"%H:%M")
diff=(time-start).seconds/60*0.25
return diff if start<=time<=end else "I don't see the sun!"
if __name__ == '__main__':
print("Example:")
print(sun_angle("07:00"))
print(sun_angle("01:23"))
print(sun_angle("12:15"))
#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!")
#6.00->0 7.00->15
#6.01->0.25deg
#6.04->1 12.00->90
#12.12->3
#6.20->5
#6.40->10
May 15, 2021
Comments: