Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Proportions solution in Clear category for Sun Angle by Filip_Zwolski
from datetime import time
from typing import Union
def sun_angle(time_variable: str) -> Union[int, str]:
time_variable = time_variable.split(":")
minutes = (int(time_variable[0]) * 60) + int(time_variable[1])
# Between 6:00 am and 6:00 pm
if minutes >= 360 and minutes <= 1080:
x = (90 * minutes) / 360 - 90
return x
else:
return ("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!")
Aug. 31, 2021