top of page
Writer's pictureKrunal Chandan

Python #9 : Write a function



Welcome all to our new blog of our first series i.e., HackerRank Python Solutions, where we provide solutions to the problems given on HackerRank Website of Python.



So today's topic is writing a function.



The below code will be used or we could use to solve this type of problem. After spending nearly half an hour for just one error you are both convinced that you are dumb at start and genius at last. So here don't be dumb, just copy this code and paste it there you will be getting you next star very fast.


Code :

if year % 4 == 0: leap = True # Check if year is divisible by 100 if year % 100 == 0: leap = False # Check if year is divisible by 400 if year % 400 == 0: leap = True return leap


Explanation : This will check first for the leap year by just checking if the number is divisible by 4 or not then it will check if it is divisible by 100, coz leap year is not divisible by 10p, then it will check if it is divisible by 400, as leap year is divisible by 400.


Hence it will just change the value of Leap variable to trye and false, and this is only we had been asked in the problem. So if have any doubts please comment below. I am sure that we can solve your comment.


Till Then, #Coders😎

11 views0 comments

Recent Posts

See All

Last Blogg For KNBLOGGS

My last blogg about gaming from your android, or my other blogs, that I published earlier were not a big hit, not like this website or...

Comments


About Us

LOGO_MAIN.jpg

Welcome to KN Blogg, the place where we're serious about tech, finance, movies, and games. Or at least, we try to be. We're a team of self-proclaimed experts, enthusiasts, and sometimes just plain clueless individuals, who love to share our thoughts, opinions, and occasional witty remarks with the world.

Posts Archive

Tags

bottom of page