728x90
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!")
728x90
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO] Solve All the same (0) | 2021.01.07 |
---|---|
[CheckIO] Solve split list (0) | 2021.01.05 |
[CheckIO] pawn-brotherhood (0) | 2021.01.02 |
[CheckIO] sort array by element frequency (0) | 2020.12.30 |
[CheckIO] Second Index (0) | 2020.12.24 |
댓글