본문 바로가기

Python_Matter/Solve

Python Learn the basics Quiz 89

반응형

Q>

Friday 13th or Black Friday is considered as unlucky day.

(금요일 13 일 또는 검은 금요일은 불행한 날로 간주됩니다.)

Calculate how many unlucky days are in the given year.

(주어진 해에 얼마나 많은 불행한 날이 오는지 계산하십시오.)

Find the number of Friday 13th in the given year.

(해당 연도의 13 번째 금요일 수를 찾습니다.)

 

Input: Year as an integer.

        (정수로 표시된 연도입니다.)

 

Output: Number of Black Fridays in the year as an integer.

           (연중 흑인 금요일 수를 정수로 나타냅니다.)

 

Example:

checkio(2015) == 3
checkio(1986) == 1

 

Precondition: 1000 < |year| < 3000

 

A>

from datetime import date

def checkio(year: int) -> int:
    s = 0
    for i in range(12):
        # date : datime에 날짜 관련
        if date(year, i + 1, 13).weekday() == 4:
            s += 1
    return s

if __name__ == '__main__':
    print("Example:")
    print(checkio(2015))

    # These "asserts" using only for self-checking and not necessary for auto-testing
    assert checkio(2015) == 3, "First - 2015"
    assert checkio(1986) == 1, "Second - 1986"
    print("Coding complete? Click 'Check' to earn cool rewards!")

 

O>

Example:
3
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 91  (0) 2019.06.21
Python Learn the basics Quiz 90  (0) 2019.06.21
Python Learn the basics Quiz 88  (0) 2019.06.21
Python Learn the basics Quiz 87  (0) 2019.06.21
Python Learn the basics Quiz 86  (0) 2019.06.21