WebAug 30, 2024 · function centuryFromYear (year) { var x = Math.floor (year / 100); if (year % 100 === 0) return x; else return x + 1; } Add an extra check in your function that checks if the year is a rounded century like 2000 or 1800. Here's how that would look. WebJoin our Discord server and chat with your fellow code warriors
cw_python_solutions/Century_From_Year.md at master
WebAug 8, 2024 · Century From Year codewars js Introduction The first century spans from the year 1 up to and including the year 100 , The second – from the year 101 up to and … WebFeb 17, 2024 · The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. Task Given a year, return the century it is in. def century (year): # Finish this :) if year % 10 == 0: return (year // 100) else: return (year // 100) +1 print (century (8110)) free consultation for divorce in wisconsin
Century From Year Codewars
WebSep 22, 2024 · My Code: def centuryFromYear (year): century = year/100 decimal = int (str (century [-2:-1])) integer = int (str (century) [:2]) if decimal > 0: return integer + 1 else: return integer print (centuryFromYear (2024)) This doesn't seem to work in certain cases. like when year = 2001 or year = 2000. WebStudy group. Collaborate with peers in your dedicated #study-group channel.. Code reviews. Submit projects for review using the /review command in your #code-reviews channel Web54 rows · The first century spans from the year 1 up to and including the year 100, the second century ... free consultation for divorce lawyer