0
所以,下面我得到:return century == year // 100 + 1 or century == year/100
的Python 3布爾
不過,我不滿足最後一個:
>>>in_century(2013, 20)
False
如何讓這個是隻有真要是世紀恰好等於一年除以100? 另外,是表達式的格式或多或少正確的嗎?
謝謝!
這裏有一個問題:
def in_century(year, century):
'''(int, int) -> bool
Return True iff year is in century.
Remember, for example, that 1900 is the last year of the 19th century,
not the beginning of the 20th.
year will be at least 1.
>>> in_century(1994, 20)
True
>>> in_century(1900, 19)
True
>>> in_century(2013, 20)
False
'''
(year - 1)// 100 + 1 – cerkiewny