UltraLowTemp-Physics 2021. 1. 3. 14:03

Problem: py.checkio.org/en/mission/sun-angle/

My Solution

def sun_angle(time):
    #replace this for solution
    
    hour, min = map(int,time.split(':'))
    
    def angle_from_the_sun(hour, min):
        degree_per_min = float(360 / (60*24))
        time = 60 * (hour - 6) + min 
        return round(degree_per_min * time, 2)
    
    if (6 <= hour < 18) or (hour == 18 and min == 0):
          return angle_from_the_sun(hour, min)
    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!")