All right, guys, in the next lesson, I've got a leap year coding challenge for you, and this is 1
a really interesting challenge. Although it is a little bit challenging, but it's really cool because 2
have you ever wondered what makes a particular year a leap year and what makes another year, not a 3
leap year? 4
And it's easy enough to say that every four years it's a leap year. 5
But if you just got given a random year and you had to work out if it was a leap year, then there's 6
actually rules that you can follow to figure this out. 7
So the rules are that on every year that is evenly divisible by 4, is a leap year, except every 8
year that is evenly divisible by 100. 9
So it's so if it's divisible by 4, but it's divisible by 100, then it's not a leap year unless 10
that year is also evenly divisible by 400. 11
So the rules are a little bit complex, but it might be easier if you look through some of the examples. 12
So, for example, if we wanted to figure out whether if year 2000 is a leap year, 2000 divide by four 13
divides cleanly, 500 with no remainder 14
so it's a leap year. When we divide 2000 by 100, then it's 20 15
so it also divides cleanly. 16
So it's actually now not a leap year. 17
But, but, but, 2000 divide by 400 equals 5 with no remainder 18
so finally, it actually is a leap year. 19
And you can look through the different examples and also if you scroll down, you can 20
take a look at this website of known leap years and they show you step by step each of the rules that 21
we talked through just now. 22
And you can test different years, such as the year 2000. 23
And you can see it step by step to see how they figured out whether if it is a leap year or not. 24
Now, I also recommend actually watching this video that I linked to up at the top 25
if you're not familiar with the concept of leap years. And even if you do understand leap years, it's 26
still a fantastic video to really understand how we're adjusting for a mismatch in the Earth's rotation 27
with the seasons. 28
So I recommend taking a look at the video, reading through each of these statements and taking a look 29
at the known leap years and the website that it links to, and then to start thinking about how you 30
would write this logic. 31
Now, in order to map out the logic, I recommend creating a flow chart of your own on draw.io and to 32
use the flow chart to see how your code should flow. 33
Now, if you want a little bit of extra help, I'm about to reveal the flow chart that I've created. 34
If you want to first try to create your own and see if you get it right, then pause the video now. 35
All right. 36
So let's take a look at the flow chart that I created. 37
If you click on this link in hint #3, you'll be taken to a page that looks like this. 38
And so if we map out those rules and we click start, we see is it clearly divisible by four? 39
If no, then it's definitely not a leap year. 40
But if it is, then we have to check the next thing. 41
Is it cleanly divisible by 100? 42
No. 43
Well, then it's definitely a leap year. 44
But if it's yes, then we have to check the final thing. 45
Is it cleanly divisible by 400? 46
If yes, then it's a leap year. 47
If no, it's not a leap year. 48
And that flow chart basically translates these three lines of logic. 49
Now, if English is not your first language, then I recommend to take a look at the flow chart and 50
also take a look at the rules for a leap year in your own language. 51
But once you're happy that you understand what's going on, then it's time to tackle the challenge and 52
write your code. 53
Now, remember, you have to output exactly the words 'Leap year.' or 'Not leap year.' 54
and look at the capitalization and where the spaces and full stops go. 55
That way, when you check solution, you'll actually be able to pass your code if everything is correct. 56
So head over to the next lesson and tackle this challenge now.