본문 바로가기

Python_Matter/Solve

Python Learn the basics Quiz 72

반응형

Q>

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.

(모든 진정한 여행자는 3 가지 방법을 알아야합니다. 화재를 해결하고 물을 찾아 주위의 자연에서 유용한 정보를 추출하십시오.)

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.

(입력 데이터 : 태양은 오전 6시에 동쪽에서 상승하는데, 각도는 0도에 해당합니다.)

At 12:00 PM the sun reaches its zenith, which means that the angle equals 90 degrees.

(12:00 PM에 태양은 정점에 도달하는데, 이는 각도가 90 도임을 의미합니다.)

6:00 PM is the time of the sunset so the angle is 180 degrees.

(오후 6시는 일몰 시간이므로 각도는 180도입니다.)

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!".

(입력이 밤 시간 (오전 6시 이전 또는 오후 6시 이후)이되면 함수는 "태양이 보이지 않습니다!"라고 반환해야합니다.)

 

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!"

 

How it is used: One day it can save your life, if you'll be lost far away from civilization.

                     (어느 날 문명에서 멀리 떨어진다면 당신의 생명을 구할 수 있습니다.)

 

Precondition: 00:00 <= time <= 23:59

 

A>

def sun_angle(time):
    #replace this for solution
    h, m = map(int, time.split(':'))
    angle = 15 * h + m / 4 - 90
    return angle if 0 <= angle <= 180 else "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!")

 

O>

Example:
15.0
Coding complete? Click 'Check' to earn cool rewards!

Process finished with exit code 0

 

S>

https://py.checkio.org

 

반응형

'Python_Matter > Solve' 카테고리의 다른 글

Python Learn the basics Quiz 74  (0) 2019.06.20
Python Learn the basics Quiz 73  (0) 2019.06.19
Python Learn the basics Quiz 71  (0) 2019.06.17
Python Learn the basics Quiz 70  (0) 2019.06.15
Python Learn the basics Quiz 69  (0) 2019.06.15