Every true traveler must know how to do 3 things: fix the fire, find the water and extract useful information from the nature around him. Programming won't help you with the fire and water, but when it comes to the information extraction - it might be just the thing you need.
Your task is to find the angle of the sun above the horizon knowing the time of the day. Input data: the sun rises in the East at 6:00 AM, which corresponds to the angle of 0 degrees. At 12:00 PM the sun reaches its zenith, which means that the angle equals 90 degrees. 6:00 PM is the time of the sunset so the angle is 180 degrees. If the input will be the time of the night (before 6:00 AM or after 6:00 PM), your function should return - "I don't see the sun!".
Input: The time of the day.
Output: The angle of the sun, rounded to 2 decimal places.
Example:
sun_angle("07:00") == 15
sun_angle("12:15"] == 93.75
sun_angle("01:23") == "I don't see the sun!"
* 시간에 따른 각도 계산
* 6:00에서18:00시 사이의 각도만 계산
-풀이
def sun_angle(time):
h,m = map(int, time.split(":"))
# 한시간에 15도
# 1분에 0.25도
angle = (15*h) + (0.25*m) - 90
return angle if 0 <= angle <=180 else "I don't see the sun!"
'취미생활 > CheckIO' 카테고리의 다른 글
[checkIO]Home 12.Xs and Os Referee (0) | 2020.02.19 |
---|---|
[checkIO]Home 11.Bird Language (0) | 2020.02.17 |
[checkIO]Home 08. Long Repeat (0) | 2020.02.16 |
[checkIO]Home 07.Flatten a List (0) | 2020.02.16 |
[checkIO]Home 06.Sort Array by Element Frequency (0) | 2020.02.13 |